2008-07-18 14:04:47 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
START=46
|
|
|
|
STOP=46
|
|
|
|
|
|
|
|
start_service() {
|
|
|
|
local section="$1"
|
|
|
|
|
|
|
|
include /lib/network
|
|
|
|
scan_interfaces
|
|
|
|
config_load /var/state/network
|
|
|
|
|
|
|
|
config_get LAN lan ifname
|
|
|
|
config_get tnlifname "$section" tnlifname
|
|
|
|
config_get remoteip4 "$section" remoteip4
|
|
|
|
config_get localip4 "$section" localip4
|
|
|
|
config_get localip6 "$section" localip6
|
2009-03-10 09:24:17 +00:00
|
|
|
config_get remoteip6 "$section" remoteip6
|
|
|
|
config_get ttl "$section" ttl
|
|
|
|
config_get mtu "$section" mtu
|
2008-07-18 14:04:47 +00:00
|
|
|
|
|
|
|
ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255
|
|
|
|
ifconfig $tnlifname up
|
2009-03-10 09:24:17 +00:00
|
|
|
ip link set mtu $mtu dev $tnlifname
|
|
|
|
ip tunnel change $tnlifname ttl $ttl
|
2008-07-18 14:04:47 +00:00
|
|
|
ip addr add $localip6 dev $tnlifname
|
2009-03-10 09:24:17 +00:00
|
|
|
ip -6 route add 2000::/3 via $remoteip6
|
2008-07-18 14:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_service() {
|
|
|
|
local section="$1"
|
|
|
|
|
|
|
|
include /lib/network
|
|
|
|
scan_interfaces
|
|
|
|
config_load /var/state/network
|
|
|
|
|
|
|
|
config_get LAN lan ifname
|
|
|
|
config_get tnlifname "$section" tnlifname
|
|
|
|
config_get remoteip4 "$section" remoteip4
|
|
|
|
config_get localip4 "$section" localip4
|
|
|
|
config_get localip6 "$section" localip6
|
2009-03-10 09:24:17 +00:00
|
|
|
config_get remoteip6 "$section" remoteip6
|
|
|
|
config_get ttl "$section" ttl
|
|
|
|
config_get mtu "$section" mtu
|
2008-07-18 14:04:47 +00:00
|
|
|
|
2009-03-10 09:24:17 +00:00
|
|
|
ip -6 ro del 2000::/3 via $remoteip6
|
2008-07-18 14:04:47 +00:00
|
|
|
ip -6 ro del ::/0 dev $tnlifname
|
|
|
|
ip addr del $localip6 dev $tnlifname
|
|
|
|
ifconfig $tnlifname down
|
|
|
|
ip tunnel del $tnlifname
|
|
|
|
}
|
|
|
|
start() {
|
2008-10-11 13:18:04 +00:00
|
|
|
if ! [ -x /usr/sbin/ip ]; then
|
2008-07-18 14:04:47 +00:00
|
|
|
echo "ip is required to setup the tunnel";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
config_load "6tunnel"
|
|
|
|
config_foreach start_service 6tunnel
|
|
|
|
}
|
|
|
|
|
|
|
|
stop () {
|
|
|
|
config_load "6tunnel"
|
|
|
|
config_foreach stop_service 6tunnel
|
|
|
|
}
|