Configuring a 6to4 tunnel on the pfSense firewall
If you’ve read my article on connecting to the IPv6 Internet, you should be familiar with the principles of IPv6 over IPv4 connectivity and have some basic IPv6 knowledge.
I’ve wanted to use IPv6 with my pfSense firewall for quite some time but it seems that the developers don’t want to be bothered supporting it. Fear not! There is a way to get IPv6 connectivity, though it won’t work through the GUI.
I won’t go into a great amount of detail on configuring your end PCs for IPv6 connectivity except to say that it’s generally turned on by default for Linux, you need to add “ipv6_enable” and reboot for FreeBSD, and that you need to add the IPV6 protocol in Windows XP (newer versions have it enabled by default). From that point on, your computer should send out solicitation messages which your pfSense firewall will respond to and you’ll get allocated an IPv6 address.
For the remainder of this article, I’m using this article (cached version here) for my template. That article is intended for native IPv6 connectivity, not tunneled connectivity. Also note that you should have configured an IPv6 over IPv4 tunnel. I suggest using a provider such as Hurricane Electric. Lastly, once you have a tunnel configured, you’ll want to allow pings from the tunnel’s endpoint to your router so it knows your side is up. I enabled this by going to Firewall/Rules and adding a ping rule that allows only the IPv4 tunnel endpoint to ping your firewall’s external IP. Use ICMP, then Any ICMP type, then specify the host IP of the remote tunnel endpoint. Don’t forget to apply it!
For your pfSense box, you’ll want to be running the latest release (1.2.3-RELEASE as of this writing). Be sure to enable SSH from the web gui since you’ll need to log into the command line. For your tunnel settings, I’ll assume the following addresses:
- WAN IPv6 IP: 2001:db8:0:1::2
- WAN IPv4 IP: 192.0.2.2
- WAN IPv4 Tunnel Destination: 192.0.2.15
- LAN IPv6 allocation: 2001:db8:0:2::/64
Log into your firewall using the credentials you configured when you first set it up. At the menu, use option 8 to drop to a shell. Next, create the following file:
#!/bin/sh # IFOUT = outside interface # IFIN = inside interface # DFGW = default gateway IFOUT="gif0" IFIN="bge0" DFGW="2001:db8:0:1::1" ####### Configure the stuff # Configure the interfaces ifconfig $IFOUT create ifconfig $IFOUT tunnel 192.0.2.2 192.0.2.15 ifconfig $IFOUT inet6 2001:db8:0:1::2 prefixlen 64 route -n add -inet6 default 2001:db8:0:1::1 ifconfig $IFOUT up ifconfig $IFIN inet6 alias 2001:db8:0:2::1 prefixlen 64 # Set the default route route -n add -inet6 default $DFGW # Configure IPv6 forwarding sysctl net.inet6.ip6.forwarding=1 # My /etc/rtadvd.conf looks like this # # bce1:\ # :addrs#1:addr="2001:db8:0:2::":prefixlen#64:tc=ether: # # Startup rtadvd /usr/sbin/rtadvd -d -D -c /etc/rtadvd.conf $IFIN
Save this file as 00_config-ipv6-if.sh under /usr/local/etc/rc.d/ so it will automatically be executed upon reboot and change the permissions to 755 so it has permissions to execute. Don’t forget to change the inside interface to the name of your interface.
Next we need to configure the pf firewall to allow the tunnel to work. Create a file with the following contents:
#!/bin/sh
#
# IFOUT = outside interface
# IFIN = inside interface
# DFGW = default gateway
IFOUT="gif0"
IFIN="bge0"
####### Configure the stuff
# Configure PF
# pfSense puts it's rules in /tmp/rules.debug for debugging purposes after boot
# We will use these rules, add IPv6 additions, read the config with pfctl and
# disable and enable PF
cat /tmp/rules.debug | sed "/User-defined rules follow/{
p;s/.*/\
pass in quick on $IFIN inet6 from any to any\\
pass out quick on $IFIN inet6 from any to any\\
pass out quick on $IFOUT inet6 from any to any\\
pass quick proto ipv6-icmp from any to any\\
# pass in on $IFOUT inet6 proto tcp from any to any port 22\\
/;}" > /tmp/rules.config-ipv6.txt
# Read the new PF configuration file
pfctl -f /tmp/rules.config-ipv6.txt
pfctl -d; pfctl -e
Save this file as 10_config-ipv6-pf.sh under /usr/local/etc/rc.d/ and chmod it to 755 so it can execute on startup.
Lastly, create /etc/rtadvd.conf and add the following to it:
bge1:\ :addrs#1:addr="2001:db8:0:2::":prefixlen#64:tc=ether:
Save that file. At this point you can either reboot your pfSense box or execute the two scripts. You should have IPv6 connectivity through your tunnel. You can test it using traceroute6 and ping6. Another great test to try is to go to http://ipv6.google.com. If the logo bounces, you have IPv6 connectivity.
Enjoy!