tags:

views:

553

answers:

3

I work with embedded Linux systems that sometimes want to get their IP address from a DHCP server. The DHCP Client client we use (dhcpcd) has limited retry logic. If our device starts up without any DHCP server available and times out, dhcpcd will exit and the device will never get an IP address until it's rebooted with a DHCP server visible/connected. I can't be the only one that has this problem. The problem doesn't even seem to be specific to embedded systems (though it's worse there). How do you handle this? Is there a more robust client available?

+2  A: 

The reference dhclient from the ISC should run forever in the default configuration, and it should acquire a lease later if it doesn't get one at startup.

I am using the out of the box dhcp client on FreeBSD, which is derived from OpenBSD's and based on the ISC's dhclient, and this is the out of the box behavior.

See http://www.isc.org/index.pl?/sw/dhcp/

Daniel Papasian
+2  A: 

You have several options:

  1. While you don't have an IP address, restart dhcpcd to get more retries.
  2. Have a backup static IP address. This was quite successful in the embedded devices I've made.
  3. Use auto-IP as a backup. Windows does this.
Jason Cohen
This is a good answer. The asker should remember that having the DHCP client broadcast forever could be bad behavior in some environments.
benc
+1  A: 

Add to rc.local a check to see if an IP has been obtained. If no setup an 'at' job in the near future to attempt again. Continue scheduling 'at' jobs until an IP is obtained.

jpbarto