#! /bin/sh touch /var/lock/ipv6tb case"$1"in start) setsid /usr/bin/tb_userspace tb [HE 隧道服务器的 IPv4 地址] [你 VPS 的 IPv4 地址] sit > /dev/null 2>&1 & sleep 1s # bring up the tunnel interface & set mtu ifconfig tb up ifconfig tb mtu 1480 # hack: show ip in ifconfig ifconfig tb inet6 add [你的 HE 隧道的客户端 IPv6 地址]/128 ifconfig tb inet6 add [分配给你的/64 地址池]::1/64 ifconfig tb inet6 add [分配给你的/48 地址池,没有就把这行删掉]::1/48 # make use of the whole ipv6 block ip -6 route add local [你的 VPS 的原生 IPv6 地址]/128 dev lo ip -6 route add local [你的 HE 隧道的客户端 IPv6 地址]/128 dev lo ip -6 route add local [分配给你的/64 地址池]/64 dev lo ip -6 route add local [分配给你的/48 地址池,没有就把这行删掉]/48 dev lo # nullroute native ipv6 to prevent sending via wrong interface ip -6 route add unreachable [你的 VPS 的原生 IPv6 地址]/128 # nullroute ipv6 tunnel to prevent sending via wrong interface ip -6 route add unreachable [你的 HE 隧道的客户端 IPv6 地址]/128 ip -6 route add unreachable [分配给你的/64 地址池]/64 ip -6 route add unreachable [分配给你的/48 地址池,没有就把这行删掉]/48 # flush route table & route the interfaces ip -6 route flush table ipv6tb ip -6 route add 2000::/3 dev venet0 src [你的 VPS 的原生 IPv6 地址] ip -6 route add 2000::/3 dev tb src [你的 HE 隧道的客户端 IPv6 地址] table ipv6tb # flush rule table ip -6 rule flush # restore routing in ipv6 tunnel address block ip -6 rule add priority 200 to [你的 HE 隧道的客户端 IPv6 地址]/128 table main ip -6 rule add priority 201 to [分配给你的/64 地址池]/64 table main ip -6 rule add priority 202 to [分配给你的/48 地址池,没有就把这行删掉]/48 table main # restore routing in native ipv6 address block ip -6 rule add priority 210 to [你的 VPS 的原生 IPv6 地址]/128 table main # restore routing to reserved ipv6 range ip -6 rule add priority 1000 to 2001:db8::/32 table main # route packets from tunnel back to the tunnel ip -6 rule add priority 30000 from [你的 HE 隧道的客户端 IPv6 地址]/128 to 2000::/3 table ipv6tb ip -6 rule add priority 30001 from [分配给你的/64 地址池]/64 to 2000::/3 table ipv6tb ip -6 rule add priority 30002 from [分配给你的/48 地址池,没有就把这行删掉]/48 to 2000::/3 table ipv6tb # restore ipv6 main route & flush cache ip -6 rule add priority 32766 from all table main ip -6 route flush cache ;; stop) ifconfig tb down # restore rule table ip -6 rule flush ip -6 rule add priority 32766 from all table main pkill -9 tb_userspace ;; *) echo"Usage: /etc/init.d/ipv6tb {start|stop}" exit 1 ;; esac exit 0