User avatar
usbspyder
Posts: 6
Joined: Wed May 30, 2012 8:45 pm

Failure to dhcp properly on reboot

Wed May 30, 2012 9:30 pm

This is a part solution for a problem which may catch others.

Got my Pi, got my power sorted after removing wireless mouse. So no power problems.

Next problem was dhcp.

Booted Pi attached to a D-Link wireless router. Router is configured for serving static ip's to macs. Router is also mac locked.

1st boot - no problems. Pi got IP and I browsed the web.
2nd boot - Pi failed to get an IP address.

Tracked it down to dhclient complaining about its config file where it stored the given config, so that it didn't have to ask again i presume. Except because it thinks it's errored it has to ask again.....

But my router won't serve the same IP to the same mac address for an infinite lease (ie a static one). Basic design flaw there, shouldn't matter that its been served already, if the mac matches serve it. Only solution was to reboot the router so that it forgot it had served it.

:) Solution was to turn off the static assignments and let the router server up what it wanted. Not ideal as you can never be sure what the Pi's IP is going to be.

Could of used a static IP on the Pi by editing /etc/network/interfaces but dhcp buys you a lot in auto-config of other files, eg resolve.config. Did do this while debugging, worked but prefer dhcp.

Did also edit /etc/dhcp/dhclient.conf and added in the line

Code: Select all

   send host-name "raspberry-pi1";
So that my router gives a name next to the served IP. Don't forget the semi-colon on the end of the line. I'm ever hopeful of getting more Pi's - hence the '1' on the end !

dubug
Found a post on Debian user forum with the same problem for dhclient in 2010 so a long time ago. Solution then was upgrade, i think.

http://forums.debian.net/viewtopic.php?f=5&t=58691

My broken dhclient.eth0.leases file

Code: Select all

lease {
  interface "eth0";
  fixed-address 192.168.0.112;
  option subnet-mask 255.255.255.0;
  option routers 192.168.0.1;
  option dhcp-lease-time 4294967295;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.0.1;
  option dhcp-server-identifier 192.168.0.1;
  renew never;
  rebind never;
  expire never;
}
My current dhclient.eth0.leases file

Code: Select all

$ more /var/lib/dhcp/dhclient.eth0.leases 
lease {
  interface "eth0";
  fixed-address 192.168.0.100;
  option subnet-mask 255.255.255.0;
  option routers 192.168.0.1;
  option dhcp-lease-time 604800;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.0.1;
  option dhcp-server-identifier 192.168.0.1;
  renew 3 2012/05/30 18:07:57;
  rebind 3 2012/05/30 18:07:57;
  expire 3 2012/05/30 18:07:57;
}

Return to “Troubleshooting”