ipv6tunnel.sh

#!/bin/sh
gw4='192.88.99.1'
ipv4=$(/sbin/ip route get 192.88.99.1 | grep 192.88.99.1 | /usr/bin/awk '{print $5}')
dev_ipv4=$(/sbin/ip route get 192.88.99.1 | grep 192.88.99.1 | /usr/bin/awk '{print $3}')

ipv6=$(/usr/bin/printf "2002:%02x%02x:%02x%02x::1" `/bin/echo $ipv4 | /usr/bin/tr "." " "`)
gw6=$(/usr/bin/printf "2002:%02x%02x:%02x%02x::1" `/bin/echo $gw4 | /usr/bin/tr "." " "`)

/sbin/ip -6 route flush dev tun6to4
/sbin/ip link set dev tun6to4 down
/sbin/ip tunnel del tun6to4

if /usr/bin/test ${1:-fnord} = stop; then exit 0; fi

/sbin/ip tunnel add tun6to4 mode sit ttl 64 remote $gw4 local $ipv4 dev $dev_ipv4
/sbin/ip link set tun6to4 up
/sbin/ip -6 addr add $ipv6/16 dev tun6to4
/sbin/ip -6 route add 2000::/3 dev tun6to4

ipv6tunnel.sh (alte Version)

#!/bin/sh
if [ 1 -ne $# ]; then
   echo Usage: $0 [device] 
   exit;
fi;
dev_ipv4="$*" #device mit oeffentlicher ipv4 Adresse
gw4='192.88.99.1'
 
ipv4=$(/sbin/ifconfig vpn | awk '/dr:/ { print substr($2, 6) }')
###/sbin/ip a show dev $dev_ipv4 | grep "inet " | awk '{print $2}'
 
ipv6=$(/usr/bin/printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`)
gw6=$(/usr/bin/printf "2002:%02x%02x:%02x%02x::1" `echo $gw4 | tr "." " "`)
 
/sbin/ip -6 route flush dev tun6to4
/sbin/ip link set dev tun6to4 down
/sbin/ip tunnel del tun6to4
 
if test ${1:-fnord} = stop; then exit 0; fi
 
#ip tunnel add tun6to4 mode sit ttl 64 remote any local $ipv4
ip tunnel add tun6to4 mode sit ttl 64 remote $gw4 local $ipv4 dev $dev_ipv4
# ip link set tun6to4 mtu 1280
ip link set tun6to4 up
ip -6 addr add $ipv6/16 dev tun6to4
#ip -6 route add 2000::/3 via $gw6 dev tun6to4 metric 1
ip -6 route add 2000::/3 dev tun6to4
# $IP -6 route add 2000::/3 via ::139.18.38.73 dev tun6to4 metric 1
 
# uni leipzig: 139.18.38.73
Powered by MediaWiki