Udhcpc: Difference between revisions
Rickyrockrat (talk | contribs) No edit summary |
Rickyrockrat (talk | contribs) mNo edit summary |
||
Line 14: | Line 14: | ||
Will set these parameters on the command line:<br> | Will set these parameters on the command line:<br> | ||
<b>-i eth0 -x hostname:myhostname<b><br> | <b>-i eth0 -x hostname:myhostname</b><br> | ||
The hostname will send the DHCP option to the server to tell the server the name of this client. | The hostname will send the DHCP option to the server to tell the server the name of this client. |
Revision as of 21:35, 2 January 2021
This material needs expanding ... Please help us expand this article by contributing. |
You may want to customize the behavior of the default DHCP client (udhcpc from busybox), which is called by /sbin/ifup by having "dhcp" in /etc/network/interfaces.
The default behavior is driven by the script /usr/share/udhcpc/default.script
Entries in /etc/network/interfaces for dhcp interfaces will drive the udhcpc command line. For example:
auto eth0 iface eth0 inet dhcp hostname myhostname
Will set these parameters on the command line:
-i eth0 -x hostname:myhostname
The hostname will send the DHCP option to the server to tell the server the name of this client.
Its default configuration may be overwritten by /etc/udhcpc/udhcpc.conf
Authorized key:value pairs are:
key | default value | possible values |
---|---|---|
NO_GATEWAY | - | <list of iface names> |
IF_METRIC | - | <metric value> |
IF_PEER_DNS | yes | <anything but yes> |
RESOLV_CONF | /etc/resolv.conf | no ; NO ; - |
NO_DNS | - | <list of iface names> |
Example /etc/udhcpc/udhcpc.conf:
RESOLV_CONF="no" # Prevents overwriting of /etc/resolv.conf
Custom scripts can be added as /etc/udhcpc/pre-* and /etc/udhcpc/post-* to be run before/after deconfig/renew/bound DHCP events - they must be marked as executable by root, e.g. chmod 744
As an example, /etc/udhcpc/post-bound/mtu could contain, to change the interface MTU from the default (1500) to 1492, which is useful if on ADSL (which uses 8 bytes):
r=$(/sbin/ip route | grep ^default | head -n 1) # Needs iproute2 package, rather than busybox's "ip", to change mtu /sbin/ip route replace $r mtu 1492