RESOLV_CONF="/etc/resolv.conf"[ -n "$1"]||{echo"udhcpc6:Error: should be called from udhcpc";exit1;}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"# ifconfig $interface 0.0.0.0;;
renew|bound)echo"udhcpc6:Setting IP address $ipv6 on $interface"ifconfig$interface$ipv6$NETMASK$BROADCASTif[$interface!="eth0"]&&[$interface!="bond0"]&&[$interface!="wlan0"];thenecho"udhcpc6:$interface is not allowd set router"exit0;elseecho"udhcpc6:set router for $interface"fiif[ -n "$router"];thenecho"udhcpc6:Deleting routers"while route del default gw 0.0.0.0 dev $interface;do:donemetric=0foriin$router;doecho"udhcpc6:Adding router $i"if["$subnet"="255.255.255.255"];then# special case for /32 subnets:# /32 instructs kernel to always use routing for all outgoing packets# (they can never be sent to local subnet - there is no local subnet for /32).# Used in datacenters, avoids the need for private ip-addresses between two hops.ip route add$i dev $interfacefi
route add default gw $i dev $interface metric $((metric++))donefiecho"udhcpc:Recreating $RESOLV_CONF"tmpfile="$RESOLV_CONF">"$tmpfile"foriin$dns;doecho"udhcpc: Adding DNS server $i"echo"nameserver $i">>"$tmpfile"donemv"$tmpfile""$RESOLV_CONF";;esacexit0