I work on a Linux system with "classical" network setup, i.e. there is no full featured configuration daemon running like NetworkManager. Most configuration is done by dhclient.
I need to detect situations where I have to re-run dhclient. (different subnet due to cable or network config changes). I want to run the check every 10 minutes without cutting existing connections.
What I basically need is an answer to questions like Is my IP Adress and Gateway valid for the Network I am connected to? or If I would renew my DHCP Lease, would I gett the same IP again?. To answer the first question, one could just ping some public IP like 126.96.36.199, but I need a solution that also works in big private networks I have no knowledge about. Even the default gateway might not always be pingable.
One I knew my ip is invalid I would do "dhclient -r eth0 ; dhclient eth0" to renew the lease. However, this disconnects me from internet for a short time, if I am already connected properly.
I found out that dhcping is a good tool to ask the DHCP server without actually using the result. However, I get strange results, which may even qualify for another question. It seems that dhcping only works well if I know the servers ip in advance, so there is a tool missing for the DHCP DISCOVER. (and using broadcast server adresses is unreliable)
I know that I can do hdcp discover with nmap, however, installing nmap is not a good idea due to security reasons.
Questions I'd like to ask:
- Is there a way to validate my configured ip in the context of the connected network?
- Is there a chance to have the dhclient lease renewed on demand?
- Are there tools doing a dhcp discover broadcast and printing the result?
Unlike the results of my first test, just calling dhclient -v does not solve my problem. To clarify this, my initial problem is dhclient running in a background mode (without actually renewing the lease all the time). Calling dhclient results in:
dhclient(30887) is already running - exiting.
This is not fully repoducable, though. Sometimes it succeeds. (This is why I first thought the -v option would make a difference, it does not)
So my question is: If I get this already running issue, although dclient is currently doing nothing, how to trigger a renewal for the background process?
(Rationale behind this is, that a DHCP client needs to bind to port 68. When this port is bound by the dhclient background daemon, another instance cannot be executed in foreground)