Monday, March 29, 2010

Enabling IPv6 on BSD with v4 only Internet Access

Background
For those working in the ICT industry, IPv4 exhaustion is not a new issue. Google search returns a wiki page discussing this topic in lengthshttp://en.wikipedia.org/wiki/IPv4_address_exhaustion. There is even an online counter displaying the remaining IPv4 addresses available. http://www.potaroo.net/tools/ipv4/

The only formal solution to IPv4 address shortage is using IPv6, by expanding the address space from 32bits to 128bits (along with other protocol details such as fixed header length replacing options, which I shall avoid going into details).

However, the protocol was not designed to directly interwork with IPv4 (hosts and routers). This means, IPv6 is and will exist as a "parallel universe" to the IPv4 internet the majority of us as using.

I would like to setup my BSD gateway as a IPv6 router. It establishes an IPv6 tunnel over IPv4 internet, terminating at a public Tunnel Broker. The default IPv6 route on BSD is this v6 tunnel. Its NAT clients can access IPv6 contents by routing through this machine.

Finding the Program
I did a search through BSD port tree (key word "IPv6") and found several interesting programs...
- 6tunnel http://toxygen.net/6tunnel/ 2005-08-18, Allow for non-v6 hosts (v4) to communicate with v6 hosts and vice versa
"the host computer to connect to a tunnel broker using the TSP protocol and to get the information for its tunnel"
"setup IPv6 on home machine and network for exploring IPv6 without any registration".
- Sixxs http://www.freebsd.org/cgi/cvsweb.cgi/ports/net/sixxs-aiccu/pkg-descr. Released in 2005 "This is the TIC+ heartbeart client for the public dynamic-IPv4 IPv6 tunnel beta test from the SixXS tunnel service provider."
Tunneling IPv6 over UDP through NATs, RFC 4380.

There is also a great chapter in FreeBSD handbook on getting started with IPv6.http://www.freebsd.org/doc/en/books/handbook/network-ipv6.html


Being an IPv4 user, the easiest way to access IPv6 webpages is visitinghttp://www.sixxs.net/tools/gateway/, which provides "IPv4 Gateways" to access IPv6 only sites using HTTP1.1. However, I wish to bring IPv6 directly onto my laptop and netbook connected over WiFi.

Referencing the handbook again, it suggests "Use the net/freenet6 port if you are on a dial-up connection"...which will be referred to as "gogoClient" http://www.freebsd.org/cgi/url.cgi?ports/net/freenet6/pkg-descr

Reading the ports description, this program aims at assigning IPv6 address to IPv4 end-users including hosts residing behind NAT. So, I signed up for an accounthttp://gogonet.gogo6.com/page/freenet6-services. This is required to obtain the gogoClient userguide and register for tunnel credentials (required).

In gogoClient's user-guide, there are four scenarios. Scenario three interest me most as it establishes BSD as IPv6 router on IPv4 network with delegated IPv6 prefix.

Afterwards, install the program through ports:
cd /usr/ports/net/freenet6/
make; make install
The program's configuration file is "/usr/local/etc/freenet6/gw6c.conf", herewith my configuration:
template freebsd # FreeBSD Specific
server broker.freenet6.net # default value
auth_method=any
userid=your_username # Different from gogonet web login.
passwd=your_passwd
host_type=router
if_prefix=wlan0 # internal interface routing with IPv6 tunnel interface.
prefixlen=64 # value could be 48 or 60 depending on gogoServer.
tunnel_mode v6anyv4 # v6anyv4 - gogoSERVER suggest correct encapsulation to client
log_file=3 # Set maximum verbosity option for "file" log option.
log_filename=/var/log/gw6c.log # Define full path
last_server Tsp-last-server.txt # (info) last gogoSERVER with successful connection
broker_list tsp-broker-list.txt # (info) gogoSERVER list

gogoClient program is invoked through CLI "gw6c", invoked in the directory where configuration file resides.

I live in Melbourne, Australia. Invoking gw6c returns the following message:
The Gateway6 redirection list is [ taipei.freenet6.net, sydney.freenet6.net, amsterdam.freenet6.net, montreal.freenet6.net ].
The optimized Gateway6 redirection list is [ sydney.freenet6.net, montreal.freenet6.net, taipei.freenet6.net, amsterdam.freenet6.net ].
So I updated the configuration file's "server" parameter accordingly.

I initiate the program again, and looking at the log-file "/var/log/gw6c.log". I have added some comments to the excerpt of my logs:

# gogClient version is v6.0-Release
2010/03/26 23:51:44 I gw6c: Gateway6 Client v6.0-RELEASE build Mar 16 2010-22:51:10
2010/03/26 23:51:44 I gw6c: Built on ///FreeBSD HomeFreeBSD 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Mon Feb 15 20:33:54 EST 2010 root@HomeFreeBSD:/usr/obj/usr/src/sys/HomeFreeBSD i386///
2010/03/26 23:51:44 I gw6c: Establishing connection to Gateway6 sydney.freenet6.net using reliable UDP.

# Negotiating tunnel parameters. Host requested to be "router" mode with /64 prefix, but received a /56 prefix.
2010/03/26 23:51:48 I gw6c: Sending: 'Content-length: 269(tunnel action="create" type="v6anyv4" proxy="no") (client) (address type="ipv4")local-public-ipv4(/address) (keepalive interval="30") (address type="ipv6")::(/address) (/keepalive) (router) (prefix length="64"/) (/router) (/client)(/tunnel)'

2010/03/26 23:51:48 I gw6c: Received: '200 Success(tunnel action="info" type="v6v4" lifetime="604800") (server) (address type="ipv4")(ipv4-address)(/address) (address type="ipv6")(ipv6-address)(/address) (/server) (client) (address type="ipv4")(ipv4-address)(/address) (address type="ipv6")(ipv6-address)(/address) (address type="dn")your_username.broker.freenet6.net(/address) (router) (prefix length="56")(local-ipv6-address)(/prefix) (/router) (keepalive interval="30") (address type="ipv6")(ipv6-address)(/address) (/keepalive) (/client)(/tunnel)'

# IPv6 interface, gif0, being created and configured locally. Sysctl parameters and wlan0 interface updated:
2010/03/26 23:51:48 I gw6c: /sbin/ifconfig gif0 create
2010/03/26 23:51:48 I gw6c: /sbin/ifconfig gif0 tunnel (local ipv4) (remote ipv4)
2010/03/26 23:51:48 I gw6c: /sbin/ifconfig gif0 inet6(ipv6-address) prefixlen 128 alias
2010/03/26 23:51:48 I gw6c: /sbin/ifconfig gif0 mtu 1280
2010/03/26 23:51:48 I gw6c: /sbin/route add -inet6 default (ipv6-address)
2010/03/26 23:51:48 I gw6c: /sbin/sysctl -w net.inet6.ip6.forwarding=1
2010/03/26 23:51:48 I gw6c: net.inet6.ip6.forwarding: 1 -> 1
2010/03/26 23:51:48 I gw6c: /sbin/sysctl -w net.inet6.ip6.accept_rtadv=0
2010/03/26 23:51:48 I gw6c: net.inet6.ip6.accept_rtadv: 0 -> 0
2010/03/26 23:51:48 I gw6c: /sbin/ifconfig wlan0 inet6 (local-ipv6-address) prefixlen 64

# Tunnel Creation success message...
2010/03/26 23:51:48 I gw6c: The host type is 'router'.
2010/03/26 23:51:48 I gw6c: The tunnel type is v6v4.
2010/03/26 23:51:48 I gw6c: Your IPv6 address is (ipv6-address).
2010/03/26 23:51:48 I gw6c: Your IPv6 prefix is (local-ipv6-address)/56.

Also note the gw6c script pushes the IPv6 default route onto BSD system. To check, use "netstat -rn".

I have not been able to find a startup configuration for gw6c program. However, I have enabled both IPv6 and IPv6 Gateway parameters in "/etc/rc.conf":
ipv6_enable="YES"
ipv6_gateway_enable="YES"

I use a Windows laptop as an IPv6 client, residing in the WiFi blanket. Its IPv6 address is set to match BSD's Wifi adapter (wlan0) IP subnet.

Now, I can access IPv6 webpages from my laptop... e.g. ipv6.google.com





No comments:

Post a Comment