#!/bin/bash # Create a 6to4 tunnel in linux. if [ $# -eq 0 ] then echo "Usage: $0 [delete]" exit fi ipv4=$(ifconfig $1|grep "inet addr:"|awk '{print $2}'|awk -F: '{print $2}') ipv6=$(printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`) echo "ipv4 address: ${ipv4}" echo "ipv6 address: $ipv6" if [ "$2" = "delete" ] then /sbin/ip link set dev tun6to4 down || echo duh /sbin/ip -6 route flush dev tun6to4 || echo hrm /sbin/ip tunnel del tun6to4 || echo huh echo "IPv6 tunnel has been deleted." exit fi /sbin/ip tunnel add tun6to4 mode sit ttl 255 remote any local 173.14.178.146 /sbin/ip link set dev tun6to4 up /sbin/ip -6 addr add ${ipv6}/16 dev tun6to4 /sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1 if ping6 -c 1 he.net 2>&1 1>/dev/null then echo "Verified IPv6 connectivity." else echo "Can't ping IPv6 network." fi