6

I am working on an embedded system and it uses udhcpc as its DHCP client. It seems to be running with the following parameters:

/usr/share/udhcpc # ps | grep dhcp 5366 root 2432 S udhcpc -R -b -p /var/run/udhcpc.eth0.pid -i eth0

I want to change the parameters or run my own DHCP client. I searched and I think it has something to do with ifup and /etc/network/interfaces.

iface eth0 inet dhcp

But I don't see a way to modify the DHCP client.

I would like to know

  1. how to change the parameter to udhcpc, and
  2. if it is possible to run my own DHCP client without killing udhcpc

Thanks!

some user
  • 219
  • 1
  • 2
  • 7

3 Answers3

3

Your system seems a lightweight version/variation of Debian, based in busybox.

busybox is typically used either for recovery medium, or for embedded systems with limited resources.

For modifying the parameters, you can invoke udhcpc automatically.

You can change /etc/network/interfaces as:

iface eth0 inet manual
   pre-up /sbin/udhcpc -R -b -p /var/run/udhcpc.eth0.pid -i eth0

As for running another DHCP client, you would have to install it; however you would have to switch it with udhcpc unless you have other interfaces.

Bear in mind as udhcpc is part of busybox, it is just a link to a global binary that provides you with a work environment, and as such, you won't save any space switching DHCP clients.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
1

How to change the parameter to udhcpc?

You can use udhcpc_opts for this.

iface eth0 inet dhcp
  udhcpc_opts -t 10
  ...

The example above tells udhcpc to try at most 10 times to get a lease.

1

The solution proposed by Martin Trenkmann didn't work for me (using udhcpc_opts). However, on my system adding the following lines to /etc/network/interfaces worked:

auto eth0
iface eth0 inet dhcp
        hostname myhostname

This made BusyBox to execute:

$ ps aux| grep dhc
 1685 root     /sbin/udhcpc -n -p /run/udhcpc.eth0.pid -i eth0 -x hostname:myhostname

(Found at https://wiki.alpinelinux.org/wiki/Udhcpc)

Edward
  • 2,364
  • 3
  • 16
  • 26
Sebastian
  • 11
  • 2