PATCH: udhcpc -- don't request set of options by default
Denys Vlasenko
vda.linux at googlemail.com
Tue Apr 1 15:14:14 PDT 2008
On Tuesday 01 April 2008 23:09, L. Gabriel Somlo wrote:
> Last, but not least, a slightly more complex sample udhcpc.script,
> which attempts to react to changes in parameters returned by the dhcp
> server in a minimal-effort sort of way (i.e. don't reconfigure the
> interface if the only change was in the list of ntp servers, etc.)
Imagine that I have *two* interfaces, both sit on DHCP configured
networks (*different* networks).
Here one "deconfig"-ed iface will happily nuke /etc/resolv.conf
created by another interface:
+case "$1" in
+ deconfig)
+ ip addr flush dev $interface
+ ip link set up dev $interface
+ rm -f $CFG
+ if [ "$PEERDNS_IF" == "$interface" ] ; then
+ [ -f ${RESOLV_CONF}.dhcsave ] && mv -f ${RESOLV_CONF}.dhcsave $RESOLV_CONF
+ fi
+ if [ "$PEERNTP_IF" == "$interface" ] ; then
+ [ -f ${NTP_CONF}.dhcsave ] && mv -f ${NTP_CONF}.dhcsave $NTP_CONF
+ fi
+ ;;
+ bound)
+ set > $CFG
+ ip addr flush dev $interface
+ [ -n "$mtu" ] && ip link set mtu $mtu dev $interface
+ ip addr add ${ip}/${mask} dev $interface
+ [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
+ if [ "$PEERDNS_IF" == "$interface" ] ; then
+ [ -f $RESOLV_CONF ] && mv -f $RESOLV_CONF ${RESOLV_CONF}.dhcsave
+ [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
+ for i in $dns ; do
+ echo nameserver $i >> $RESOLV_CONF
+ done
+ fi
Attempt to correctly express configurational logic in dhcp scripts
is doomed to fail IMO. It will only get more and more contrived
when you try to cater for more and more weird races.
I tried to explain it here:
http://busybox.net/~vda/no_ifup.txt
--
vda
More information about the busybox
mailing list