1 # set up an ipv6 tunnel
6 if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then
7 print 'ipv6 tunnel already set up, nothing to be done.'
8 print 'execute: "ifconfig sit1 down ; ifconfig sit0 down" to remove ipv6-tunnel.' ; return 1
10 [[ -n "$PUBLIC_IP" ]] || \
11 local PUBLIC_IP=$(ifconfig $(route -n | awk '/^0\.0\.0\.0/{print $8; exit}') | \
12 awk '/inet addr:/ {print $2}' | tr -d 'addr:')
14 [[ -n "$PUBLIC_IP" ]] || {
15 print 'No $PUBLIC_IP set and could not determine default one.'
18 local IPV6ADDR=$(printf "2002:%02x%02x:%02x%02x:1::1" $(print ${PUBLIC_IP//./ }))
19 print -n "Setting up ipv6 tunnel $IPV6ADDR via ${PUBLIC_IP}: "
20 ifconfig sit0 tunnel ::192.88.99.1 up
21 ifconfig sit1 add "$IPV6ADDR" && print done || print failed
25 if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then
26 print 'ipv6 tunnel available' ; return 0
28 print 'ipv6 tunnel not available' ; return 1
32 if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then
33 print -n 'Stopping ipv6 tunnel (sit0 + sit1): '
34 ifconfig sit1 down ; ifconfig sit0 down && print done || print failed
36 print 'No ipv6 tunnel found, nothing to be done.' ; return 1
40 print "Usage: ipv6-tunnel [start|stop|status]">&2 ; return 1