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