加载中...
udhcpc6嵌入式获取IPV6

获取命令

udhcpc6 -b -i -eth0
# -s 可以指定dhcpc的脚本文件路径

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"
#		ifconfig $interface 0.0.0.0
		;;

	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
	# 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 $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
上一篇:
busybox编译以及添加menuconfig配置选项
下一篇:
IPV6服务器搭建
本文目录
本文目录