wiki:router
Last modified 7 years ago Last modified on 11/13/10 18:09:49

Infos für mein Linksys wrt54gl

uname -a
Linux router 2.6.32.10 #20 Tue Apr 6 15:53:48 CEST 2010 mips GNU/Linux

ipv6 tunnel using anycast Tunnel

setup ipv6 tunnel as hotplug part of the interface:
/etc/hotplug.d/iface/30-ipv6tunnel

. /etc/functions.sh
COMMAND=/usr/sbin/ip

#settings for 6to4 tunnel
ipv6subnet="6464" # local subnet ip. any 4 digit number will do
relay6to4="192.88.99.1" #6to4 anycast ip. or a known 6to4 gateway.
name6to4="tun6to4" #name of the tunnel device to create.
	
if [ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ]; then
	if [ -x $COMMAND ]; then
		# get interfaces
		lanif="$(uci -P /var/state get network.lan.ifname)"
		wanif="$(uci -P /var/state get network.wan.ifname)"
		# construct 6to4 address.
		ipv4=$(ifconfig $wanif | grep 'inet addr' | awk '{print $2}' | cut -d':' -f 2)
		ipv6prefix=$(echo $ipv4 | awk -F. '{ printf "2002:%02x%02x:%02x%02x", $1, $2, $3, $4 }')
		# setup tunnel
		logger '6to4tunnel: Setting up "'$name6to4'" with 6to4 prefix "'$ipv6prefix'::1/16" on "'$wanif'" created from ip "'$ipv4'"'
		ip tunnel add $name6to4 mode sit ttl 64 remote any local $ipv4
		ip link set dev $name6to4 up
		ip -6 addr add ${ipv6prefix}::1/16 dev $name6to4
		ip -6 route add 2000::/3 via ::${relay6to4} dev $name6to4 metric 1
		ip -6 addr add ${ipv6prefix}:${ipv6subnet}::1/64 dev $lanif
		echo "done setting 6to4tunnel"
		#ensure we route ipv6
		sysctl -w net.ipv6.conf.all.forwarding=1
	else
		logger "Fatal: can not find ip command. not setting up 6to4 tunnel!"
	fi;
fi;
if [ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ]; then
	if [ -x $COMMAND ]; then
		lanif="$(uci -P /var/state get network.lan.ifname)"
		#as we dont have the ip on the wan interface anymore, we need get the ipv6 prefix from the tunell devices itself.
		ipv6prefix='2002:'$(ip addr show $name6to4 | grep "inet6 2002:" | cut -f2,3 -d':')
		lanip=$(ip addr show $lanif | grep "inet6 ${ipv6prefix}:${ipv6subnet}::1/64" | cut -f6 -d' ')
		echo $lanip
		if [ -z "$lanip" ]; then
			logger '6to4tunnel: no lan ip found to delete.';
		else
			ip -6 addr del ${lanip} dev ${lanif}
			
		fi;
		if [ -z "$ipv6prefix" ]; then
			logger '6to4tunnel: no 6to4 prefix found'
		else
			ip -6 route flush dev ${name6to4}
		fi;
		ip link set dev $name6to4 down
		ip tunnel del $name6to4
		logger '6to4tunnel: 6to4 tunnel destroyed'
	fi;
fi;

linke radvd startup script in rc.d:

ln -s /etc/init.d/radvd /etc/rc.d/S85radvd

DNS setup

config -> interface wan -> dns 192.168.28.99

config 'interface' 'wan'
	option 'ifname' 'eth0.1'
	option 'proto' 'dhcp'
	option 'defaultroute' '0'
	option 'peerdns' '0'
	option 'dns' '192.168.28.99'

port forwarding

  • 55555 -> 192.168.28.99