[1.16.2] Using udhcpc?

Laurent Bercot ska-dietlibc at skarnet.org
Wed Jun 22 10:35:11 UTC 2011


> 3. Am I correct in understanding that udhcpd.conf is for the DHCP
> server, not the client?

 Yes. As the name implies, this file is used by udhcpd (d for daemon),
not by udhcpc (c for client).


> 4. If udhcpc only calls scripts, what's the point of udhcpc?

 udhcpc implements the DHCP protocol per se. It finds a DHCP server and
obtains a lease (an IP address for some amount of time) from it. That's
what udhcpc is for (you definitely do not want to speak DHCP by hand).
 Then udhcpc calls scripts so you can do what you want with the IP address
and other data it got. Typically, when you obtain a lease, you perform
at least the following:
 1. configuring your network interface.
 2. configuring your routing tables
 3. configuring your DNS, if applicable

 If your udhcpc command line is "udhcpc -f -i eth0 -s myscript"
then "myscript" will be automagically called when an event occurs, with
an argument ($1) telling you what happened: bound, leasefail, deconfig,
nak or renew.
 "myscript" should perform the appropriate tasks (configuring or
deconfiguring your interface/routes/DNS, at least) for the event that
occurred.


> 5. What is the right way to release IP configuration and kill udhcpc?

 Just send a SIGTERM to the udhcpc process. Supervision tools such as
runit (runsv and friends are included with busybox) can help you manage
it without you needing to know udhcpc's PID. Just remember to call
udhcpc with the "-f" option (no backgrounding) in your run script.


> root:/var/tmp> udhcpc deconfig -s /var/tmp/simple.script

"deconfig" is an argument that is automatically given to the script when
a deconfig happens; do not call udhcpc manually with such arguments.
udhcpc should only be run once, when you start it; kill it to end the
service.

-- 
 Laurent


More information about the busybox mailing list