Services and tunnels
udhcpc
Asks the network for an address with DHCP and applies what the server offers: address, gateway, DNS.
A DHCP client broadcasts a Discover, gets an Offer, Requests it and receives an Ack
(DORA). The lease carries more than the address: the default gateway and the DNS servers come from it too. In the
labs the client is BusyBox's udhcpc (dhclient on many distributions). A lab device that takes its address from
DHCP keeps one running, and dhcp-renew eth0 asks it to renew the lease now (dhcp-release eth0 gives it back),
printing what it got, as ipconfig /renew does on Windows. Watch the exchange with
tcpdump -ni eth0 port 67 or port 68.
udhcpc command usage
udhcpc -i CARD [-n] [-q] [-f]
Options
-
-i eth0 - the card to configure
-
-n - exit if no lease is offered
-
-q - exit once a lease is obtained
-
-f - stay in the foreground
-
-t 4 -T 2 - send 4 discovers, 2 seconds apart, before giving up
-
-s /bin/true - run this script instead of the one that applies the lease: only ask, change nothing
udhcpc examples
-
udhcpc -i eth0 -n -q - Asks for a lease on eth0 once, and exits whether or not one comes.
-
udhcpc -i eth0 -n -q -f -s /bin/true - Asks for a lease and prints it, leaving the card's address alone.
-
dhcp-renew eth0 - Has the device's running DHCP client renew eth0's lease now, and prints the lease.
-
tcpdump -ni eth0 port 67 or port 68 - Shows the DHCP exchange: discover, offer, request, ack.
Pitfalls
- DHCP is broadcast: it never crosses a router, so the server must be on the same network unless a router relays it (
ip helper-address,dhcrelay).