Difference between revisions of "Udhcpc"

From Alpine Linux
Jump to: navigation, search
(Created page with "You may want to customize behavior of default dhcp client (udhcpc from busybox). The default behavior is drived by the script /usr/share/udhcpc/default.script It's default c...")
 
m
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
You may want to customize behavior of default dhcp client (udhcpc from busybox).
+
{{Expand|Please help us expand this article by contributing.}}
  
The default behavior is drived by the script /usr/share/udhcpc/default.script
+
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.
  
It's default configuration may be overwritten by a /etc/udhcpc/udhcpc.conf file.
+
The default behavior is driven by the script /usr/share/udhcpc/default.script
  
Authorized key:value pair are available:
+
Its default configuration may be overwritten by /etc/udhcpc/udhcpc.conf
 +
 
 +
Authorized key:value pairs are:
  
 
{| cellpadding="15" border="1" class="wikitable"
 
{| cellpadding="15" border="1" class="wikitable"
Line 34: Line 36:
 
|}
 
|}
  
You may also add custom scripts /etc/udgcpc.pre-* and /etc/udgcpc.post-* to be run before and after deconfig|renew|bound dhcp events.
+
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 [https://en.wikipedia.org/wiki/Maximum_transmission_unit 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
 +
 
 +
[[Category:Networking]]
 +
[[Category:Embedded Systems]]

Latest revision as of 19:20, 9 December 2018

Tango-view-fullscreen.png
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

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