5

I am setting up a DHCP reservation for my Raspberry Pi B+ on the wired connection. It's in another room. After setting up the reservation, I told it to reboot, and it did not get the new reservation. The reservation was for a different address than it currently has.

I tried sudo dhclient and that did not grab the new address.

I tried sudo dhclient -r and that killed the connection. Now I have to walk over to it, pull the plug, and hope it grabs a new address.

While a minor inconvenience in this case, how does one force a DHCP renew from the ssh/remote prompt/console?

  • 1
    Are you sure? You can't remain connected over ssh while the IP address is changed. Did you check your router or other DHCP server device to see if it had assigned a new lease to the RPI? – Dee Hendrick Dec 25 '15 at 5:00
5

The dhclient -r may work, if the DHCP server honours it and clears the lease server side.

The problem is that you did it manually and lost the connection and control of the session.

You had to do it in a script, where you released it and asked immediately for a new one.

For extra security, you would run it in the background, though I am usually do it just running a script and it works.

Something as simple as this would be enough actually.

#!/bin/bash
dhclient -r
nohup dhclient &

Not getting the static IP after having an active DHCP lease is a common problem in DHCP servers, or at least in ISC-DHCPD. Unfortunately, the ISC DHCPD code gives priority to leases over static addresses.

So while the lease is not released, does not expire, or is not manually deleted in the DHCP server, you won't get the (new) static IP address, and will get instead the same address in the lease over and over.

Apparently the rationale is to keep the new DHCP requests coherent with the old IP addresses that were given to the machine, according to the following link.

https://lists.isc.org/pipermail/dhcp-users/2012-March/015052.html

  • The situation is so annoying I had to delete the oh so handy static IP lease helpdesk people "bribed" someone in my team to create in order to connect new printers and configure them completely over HTTP. Nobody was able to connect the dots and understand why they had to escalate to me tickets about new printers not obeying the static DHCP addresses that they created. – Rui F Ribeiro Dec 25 '15 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.