IPv6 (the next generation of TCP/IP) is becoming more widely available: Networking providers such as Comcast are beginning to offer native IPv6 to its subscribers, other providers such as Sonic.net offer IPv6 tunnels, and IPv6 Tunnel Brokers such as Hurricane Electric offer free IPv6 tunnels (no subscription necessary).
This blog post describes setting up an IPv6 tunnel under FreeBSD 9.1 as a Sonic.net subscriber.
Gathering Network Information
You can extract your IPv4 and IPv6 addresses and routes from the Sonic.net website (you will need to be a Sonic.net subscriber). First, let’s find our Sonic.net IPv4 address (this should be an address of one of your FreeBSD machine’s interfaces):
A note about Sonic.net’s IPv4 tunnel endpoint. It appears that every Sonic.net IPv6 tunnel uses the same IPv4 address for the far-end tunnel endpoint: 126.96.36.199
Next we need to find our IPv6 Address:
A note about the IPv6 address: this is actually a subnet, not an address. In IPv6, a /127 subnet is a subnet consisting of 2 IP addresses which correspond to the tunnel endpoints. The lower address, …:16c2, is Sonic.net’s. The upper address, …:16c3, is your FreeBSD machine’s.
- my IPv4 tunnel endpoint (i.e. my static IP): 188.8.131.52
- Sonic.net’s IPv4 tunnel endpoint: 184.108.40.206
- my IPv6 tunnel endpoint: 2001:05a8:0000:0001:0000:0000:0000:16c3/127
- Sonic.net’s IPv6 Tunnel Endpoint: 2001:05a8:0000:0001:0000:0000:0000:16c2
Setting up & Testing
sudo ifconfig gif0 create # tunnel: my IP, their IP: sudo ifconfig gif0 tunnel 220.127.116.11 18.104.22.168 # my IPv6 sudo ifconfig gif0 inet6 2001:05a8:0000:0001:0000:0000:0000:16c3/127 # default route is THEIR IPv6: sudo route add -net -inet6 default 2001:05a8:0000:0001:0000:0000:0000:16c2 # Let's test:
ping6 -c 4 ipv6.google.com
You’ll want the IPv6 tunnel to persist across reboots, so you’ll need to make the following changes to /etc/rc.conf:
gif_interfaces="gif0" ifconfig_gif0_ipv6="YES" gifconfig_gif0="22.214.171.124 126.96.36.199" ifconfig_gif0="inet6 2001:05a8:0000:0001:0000:0000:0000:16c3/127" static_routes="ipv6" route_ipv6="-net -inet6 default 2001:05a8:0000:0001:0000:0000:0000:16c2"