获取命令
udhcpc6 -b -i -eth0
default.script
RESOLV_CONF="/etc/resolv.conf"
[ -n "$1" ] || { echo "udhcpc6:Error: should be called from udhcpc"; exit 1; }
NETMASK=""
[ -n "$subnet" ] && NETMASK="netmask $subnet"
BROADCAST="broadcast +"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
case "$1" in
deconfig)
echo "udhcpc6:Setting IP address 0.0.0.0 on $interface"
;;
renew|bound)
echo "udhcpc6:Setting IP address $ipv6 on $interface"
ifconfig $interface $ipv6 $NETMASK $BROADCAST
if [ $interface != "eth0" ] && [ $interface != "bond0" ] && [ $interface != "wlan0" ] ; then
echo "udhcpc6:$interface is not allowd set router"
exit 0;
else
echo "udhcpc6:set router for $interface"
fi
if [ -n "$router" ] ; then
echo "udhcpc6:Deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
:
done
metric=0
for i in $router ; do
echo "udhcpc6:Adding router $i"
if [ "$subnet" = "255.255.255.255" ]; then
ip route add $i dev $interface
fi
route add default gw $i dev $interface metric $((metric++))
done
fi
echo "udhcpc:Recreating $RESOLV_CONF"
tmpfile="$RESOLV_CONF"
> "$tmpfile"
for i in $dns ; do
echo "udhcpc: Adding DNS server $i"
echo "nameserver $i" >> "$tmpfile"
done
mv "$tmpfile" "$RESOLV_CONF"
;;
esac
exit 0