10

It turns out raspberry pi doesn't try very hard to get an IP address with dhcp, during a power failure, my rpi booted faster than the dhcp server, and never got an IP address. In such a situation, the rpi seems to be booted, but it doesn't get an IP address, and I never see a dhcp request from it until I reboot it again.

dhclient is run as such:

dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0

I can't find any way to alter the arguments to dhclient, the -1 argument might be the culprt. How can I make my raspberrypi retry dhcp requests until it gets a reply ?

Edit: this is concerning the Raspbian “wheezy” distro.

nos
  • 1,106
  • 2
  • 10
  • 14

3 Answers3

7

Remove the -1 from your command line arguments, then edit the timeout and retry values in /etc/dhclient.conf to your liking. You can look at the man page (man dhclient.conf) for more details.

Munkeh
  • 681
  • 4
  • 9
1

What is the content of your /etc/network/interfaces?

I am assuming there is auto eth0 since it does query DHCP on boot.

What if you change that to allow_hotplug eth0? That should react to changes to the interface (cable inserted/removed), if i understand it correctly.

(All this is just my educated guess).

The Gruffalo
  • 271
  • 1
  • 3
  • 8
0

There's a workaround given here by Jeroen: https://bugs.launchpad.net/raspbian/+bug/1125066

I have setup the workaround and rebooted - seems ok at the moment. Will confirm if problem resolved in an update after testing for a while.

Here's the workaround:

A workaround is to create a wrapper script by renaming /sbin/dhclient to /sbin/dhclient-bin and but the text below in /sbin/dhclient and afterwards chmod it to 777:

#!/bin/sh
/sbin/dhclient-bin -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
Andy Boura
  • 101
  • 1