11

I would like to know, if there is a way I could force the DHCP server to renew the IP address of a client machine instantly, without me going to the client machine? In fact, imagine, I don't have access to the client machine.

So, here is my scenario,

The client first gets a Random IP address say A from the DHCP server initially, when it is connected to the LAN. Imagine, someone connected the client to the LAN and he didn't map any IP address to its MAC address in the dhcpd.conf to begin with.

I would like to mention here that, there are other machines in the same subnet that already have IP address to MAC address mapping configured in the dhcpd.conf.

Next, I modify the dhcpd.conf file to map a new IP address B for the client to its MAC address.

But, now I need the old IP address A to be changed instantly to B.

I don't want to tweak default-lease-time or mess around with the lease time in dhcpd.conf.

Any other ways like restarting the services are fine since, excluding that one machine, all others already have their IP addresses tied to the MAC addresses in the dhcpd.conf.

Note: I cannot reboot any machines in the LAN, not even the machine which is running the dhcp server.

Hope I made myself quite clear.

Thanks

2
  • What type of clients?
    – Mike
    Aug 18, 2012 at 11:19
  • Mike: Computers with OS installed and connected to LAN. Aug 18, 2012 at 18:07

4 Answers 4

9

The FORCERENEW provides the mechanism for the server to indicate to the client to re-new.

Not sure if it is implemented in your distro.

1
  • 1
    Unfortunately most DHCP client implementations don't support this extension. Windows systems don't (Upto and including Win7, I'm not sure about Win8, but I don't think MS overhauled the DHCP client that much.)
    – Tonny
    Aug 11, 2014 at 12:18
8

You can't thru DHCP itself. It doesn't have provisions for this.

The only thing you can do is to force the client into a disconnect/reconnect.

  • Pull the cable.
  • If the client is on a managed switch to which you have access you can disable/enable the switch-port.
  • If you can login remotely to the client and you have the required authorizations on the client you may be able to disable/enable the network interface from the client-side. That would require a script to do it which is launched without needing the "starting session" as that would be aborted as soon as the disconnect takes place. (E.g. use "nohup" on *nix command-line or use crontab.) On Windows system remotely restarting the TCPIP service will do the trick if you have an admin account for that client.
7
  • 3
    Why would client renew dhcp request in case of network outage? At least in my home they don't.
    – user130370
    Aug 18, 2012 at 12:31
  • 1
    @EricDANNIELOU: If the client cannot distinguish a network outage from just pulling the cable and pluging it on another network, it has to verify the DHCP lease. But for that, you have to tell your switch's port to actually disconnect from the cable, so that the client thinks the cable has been pulled.
    – BatchyX
    Aug 18, 2012 at 15:25
  • 2
    @EricDANNIELOU After loosing network connectivity EVERY computer needs to re-establish its DHCP lease. Otherwise it can't tell if it is still in the same LAN. For all it knows it just got re-patched into another LAN. So every OS does a DHCP (re-)acquire. You may not have noticed this, but it really happens. The fact that it usually will get the same address back as it had before, has nothing to do with this. That's just because most OS will ask the DHCP server for the same address, which is usually granted. But the DHCP server may offer a different address and that is what the poster wants.
    – Tonny
    Aug 18, 2012 at 15:35
  • 1
    tonny @BatchyX : Interesting, I'll try to figure out. Thanks for the details.
    – user130370
    Aug 18, 2012 at 16:35
  • 2
    @EricDANNIELOU Wi-Fi has no concept of "plugged cable" and "unplugged cable", your host can't distinguish between a poor link and an down AP if you don't let it disconnect the client properly. and disassociation from an AP is often not regarded as a pulled cable, because disassociation is common with poor links.
    – BatchyX
    Aug 18, 2012 at 17:00
2

It's not "instant", but this is as quick as it gets.

  1. Add the reservation in dhcpd.conf.
  2. Restart dhcpd.
  3. Sever the client-machine's network connection. (Best if you disable the managed switchport the clinet-machine is connected to, would be more tedious to pull the jumper from the patch-pannel to an unmanaged switch.)
  4. Expire old lease from dhcpd via omshell(1) by altering it's ends time to sometime in the past (e.g. 00:00:00:00).
  5. Restore the client-machine's network connection.

    • It is important that the first lease is expired, else the client machine will make a DHCPREQUEST for its first address and dhcpd will grant it as it will still be a valid lease.
    • Moving the client-machine to another VLAN without removing the lease may work, but it's a toss up as to which valid lease dhcpd will grant when the client-machine returns to its original VLAN.
    • Adding a host entry with a fixed address automatically generates a lease entry which is why the first lease's expire time is modified, rather than altering it's IP address.
1

As far as I know you can't : Dhcp server has no way to act on client once it has given them an ip adress.. And since you don't have access to the client, the only way you can change its IP is waiting for time to expire.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .