OpenStackUsage: setup_6to4_ubuntu.sh

File setup_6to4_ubuntu.sh, 1.1 KB (added by ypap, 2 years ago)
Line 
1#!/bin/bash
2
3## Parameter: choose one interface that has IPv4 connectivity (possibly through a modem/router)
4interface="wlan0"
5
6
7echo "|---------------------------------|"
8echo "| IPv6to4 Setup script for Ubuntu |"
9echo "|---------------------------------|"
10
11echo "Getting IP info..."
12ipv4_internal=$(/sbin/ifconfig $interface | grep "inet " | awk '{print $2}' | awk -F: '{print $2}')
13echo "Interface IP: $ipv4_internal"
14ipv4_external=$(curl -sf http://ipecho.net/plain; echo)
15echo "External (ISP) IP: $ipv4_external"
16ipv4to6addr=$(printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4_external | tr "." " "`)
17echo "External 6to4 IP: $ipv4to6addr"
18
19echo "Check that the above IPs are correct and press Enter to continue..."
20read
21
22set -e
23echo "Setting up links and routes..."
24/sbin/sysctl net.ipv6.conf.all.forwarding=1
25/sbin/sysctl net.ipv4.conf.all.forwarding=1
26/sbin/ip tunnel add tun6to4 mode sit remote any local $ipv4_internal
27/sbin/ip link set dev tun6to4 up
28/sbin/ip -6 addr add "$ipv4to6addr/16" dev tun6to4
29/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1
30echo "All set up, enjoy!"
31
32exit 0