<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" >

<channel>
	<title>Remco Bressers&#039; Blog &#187; stateless autoconfiguration</title>
	<atom:link href="http://remcobressers.nl/tag/stateless-autoconfiguration/feed/" rel="self" type="application/rss+xml" />
	<link>http://remcobressers.nl</link>
	<description>IT stuff that matters, travels and more</description>
	<lastBuildDate>Thu, 19 Apr 2012 13:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Configuring native IPv6 in pfSense firewall</title>
		<link>http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/</link>
		<comments>http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 10:52:49 +0000</pubDate>
		<dc:creator>Remco Bressers</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[pfSense]]></category>
		<category><![CDATA[router advertisements]]></category>
		<category><![CDATA[rtadvd]]></category>
		<category><![CDATA[stateless autoconfiguration]]></category>

		<guid isPermaLink="false">http://remcobressers.nl/?p=64</guid>
		<description><![CDATA[Today, we&#8217;re going to talk about pfSense. A software stateful-firewall based on the excellent pf firewall in FreeBSD. It&#8217;s an easy to install from-ISO appliance. From the pfSense website: pfSense is a free, open source customized distribution of FreeBSD tailored for use as a firewall and router. In addition to being a powerful, flexible firewalling [...]]]></description>
			<content:encoded><![CDATA[<p><img class="attachment wp-att-68 alignleft" src="http://remcobressers.nl/wp-content/uploads/2009/08/pfsense.png" alt="pfSense" width="300" height="110" /></p>
<p>Today, we&#8217;re going to talk about <a href="http://www.pfsense.org" target="_blank">pfSense</a>. A software stateful-firewall based on the excellent pf firewall in FreeBSD. It&#8217;s an easy to install from-ISO appliance.</p>
<p>From the pfSense website:</p>
<blockquote><p>pfSense is a free, open source customized distribution of <a href="http://www.freebsd.org/">FreeBSD</a> tailored for use as a firewall and router. In addition to being a powerful, flexible firewalling and routing platform, it includes a long list of related features and a package system allowing further expandability without adding bloat and potential security vulnerabilities to the base distribution. pfSense is a popular project with more than 1 million downloads since its inception, and proven in countless installations ranging from small home networks protecting a PC and an Xbox to large corporations, universities and other organizations protecting thousands of network devices.</p></blockquote>
<p>pfSense is a nice piece of software, but the developers don&#8217;t seem to be very interested in integrating IPv6 support in the interface. Too bad, because IPv6 is hot and <strong>will</strong> replace IPv4 within the next few years. I&#8217;m not going to integrate IPv6 in the GUI of pfsense with this tutorial, but after following the instructions you will have a working IPv6 router/firewall with support for stateless autoconfiguration. The configuration is built from my own needs, so if it doesn&#8217;t match your expectations please add your features.</p>
<p>For this setup i use pfSense 1.2.3-RC1 which is out for quite a while and pretty stable in it&#8217;s use.</p>
<p>I&#8217;m not going to discuss the installation of pfSense. If you can&#8217;t install the pfSense ISO, you shouldn&#8217;t be doing IPv6 on it anyway <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . First of all, make sure you enable SSH in pfSense. You can find the feature at &#8220;System&#8221; &gt; &#8220;Advanced&#8221;</p>
<p><a title="Enable SSH on pfSense" rel="lightbox[pics64]" href="http://remcobressers.nl/wp-content/uploads/2009/08/pfsense-ssh.png"><img class="attachment wp-att-66 alignleft" src="http://remcobressers.nl/wp-content/uploads/2009/08/pfsense-ssh.png" alt="Enable SSH on pfSense" width="300" height="54" /></a></p>
<p>After enabling, connect (via SSH) to the pfSense box. Ofcourse, if you&#8217;re sitting behind the box you can do it on the console also <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>You will be presented a nice text menu:</p>
<blockquote><p>*** Welcome to pfSense 1.2.3-RC1-pfSense on myFirewall ***</p>
<p>WAN*                     -&gt;    bce0    -&gt;    123.123.123.1<br />
LAN*                     -&gt;    bce1    -&gt;    192.168.0.254</p>
<p>pfSense console setup<br />
***********************<br />
0)  Logout (SSH only)<br />
1)  Assign Interfaces<br />
2)  Set LAN IP address<br />
3)  Reset webConfigurator password<br />
4)  Reset to factory defaults<br />
5)  Reboot system<br />
6)  Halt system<br />
7)  Ping host<br />
8)  Shell<br />
9)  PFtop<br />
10)  Filter Logs<br />
11)  Restart webConfigurator<br />
12)  pfSense PHP shell<br />
13)  Upgrade from console<br />
14)  Disable Secure Shell (sshd)</p></blockquote>
<p>We want to go to the CLI shell. Select 8.</p>
<p>On my box, i&#8217;m using Broadcom network interfaces. On FreeBSD these are named &#8216;bce0&#8242; and &#8216;bce1&#8242;. You can find the respective names with the &#8216;ifconfig&#8217; command. On my setup, bce0 is the outside interface and bce1 is the inside interface.<br />
My setup is fully native-IPv6, which means that i&#8217;m not doing any tunnelling at all. On the outside interface, i have an IPv6 address from <a href="http://www.signet.nl" target="_blank">my provider&#8217;s</a> /64 block he used for my connection. On the inside, i have  a /64 of IPv6 addresses which are publically reachable (global-unicast). Ofcourse i&#8217;m using fake addresses to prevent my firewall being bombed all-over <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Let&#8217;s say, these are my network variables :</p>
<ul>
<li>The WAN IPv6 network is : 2001:4cb8:a95:1::/64</li>
<li>The WAN IPv6 address is : 2001:4cb8:a95:1::2</li>
<li>The WAN IPv6 default gateway is : 2001:4cb8:a95:1::1</li>
<li>The LAN IPv6 network is : 2001:4cb8:b95:1::/64</li>
<li>The LAN IPv6 address is : 2001:4cb8:b95:1::1</li>
</ul>
<p>With this information, we&#8217;re going to create our boot-script to configure the interfaces and routing.</p>
<pre>cd /usr/local/etc/rc.d
vi 00_config-ipv6-if.sh

#!/bin/sh
#
# IFOUT = outside interface
# IFIN = inside interface
# DFGW = default gateway
IFOUT="bce0"
IFIN="bce1"
DFGW="2001:4cb8:a95:1::1"

####### Configure the stuff

# Configure the interfaces
ifconfig $IFOUT inet6 alias 2001:4cb8:a95:1::2 prefixlen 64
ifconfig $IFIN inet6 alias 2001:4cb8:b95:1::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:4cb8:b95:1::":prefixlen#64:tc=ether:
#
# Startup rtadvd
/usr/sbin/rtadvd -d -D -c /etc/rtadvd.conf $IFIN</pre>
<p>Ok, that&#8217;s pretty much all there is to enable IPv6 and configure the static routing to the ISP.<br />
Next, we need to change permissions on this file :</p>
<pre>chmod 755 /usr/local/etc/rc.d/00_config-ipv6-if.sh</pre>
<p>After bootup, IPv6 will be running on the pfSense box, but it won&#8217;t do a thing. This is because we need to change the filter (PF) also. This is going to be our next script.</p>
<pre>cd /usr/local/etc/rc.d
vi 10_config-ipv6-pf.sh

#!/bin/sh
#
# IFOUT = outside interface
# IFIN = inside interface
# DFGW = default gateway
IFOUT="bce0"
IFIN="bce1"

####### 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\\
/;}" &gt; /tmp/rules.config-ipv6.txt

# Read the new PF configuration file
pfctl -f /tmp/rules.config-ipv6.txt
pfctl -d; pfctl -e</pre>
<p>And change the permissions also:</p>
<pre>chmod 755 /usr/local/etc/rc.d/10_config-ipv6-pf.sh</pre>
<p>Finally, we need to configure the router advertisement daemon (rtadvd) to get stateful autoconfiguration to work.</p>
<pre>vi /etc/rtadvd.conf

bce1:\
  :addrs#1:addr="2001:4cb8:b95:1::":prefixlen#64:tc=ether:</pre>
<p>After rebooting the pfSense firewall (or run script 00 and 10) IPv6 will work on your box.<br />
But.. when you change filter rules (or anything actually) in the GUI, the filter settings are overwritten and your IPv6 connectivity will break.<br />
After some searching on the box, i noticed that after changing things in the GUI the function filter_configure_sync() is called and the rules will be flushed.<br />
This function can be found in /etc/inc/filter.inc (line 78). In the function, there&#8217;s a hook to a plugin directory. When the function filter_configure_sync() is called, the function will look in the /usr/local/pkg/pf directory for scripts, which will be executed. This only happens if scripts end with &#8220;.sh&#8221; as the extension.<br />
We will symlink the 10_config-ipv6-pf.sh script to this location to make it work.</p>
<pre>ln -s /usr/local/etc/rc.d/10_config-ipv6-pf.sh /usr/local/pkg/pf/</pre>
<p>Congratulation! You got yourself a working IPv6 setup.</p>
<p>If you want to know more ins and outs about IPv6, i suggest reading the book &#8220;Running IPv6&#8243; by Iljitsch van Beijnum. You can find more information at <a href="http://runningipv6.net/" target="_blank">http://runningipv6.net/ </a></p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fremcobressers.nl%2F2009%2F08%2Fconfiguring-native-ipv6-pfsense%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-url="http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/" data-text="Configuring native IPv6 in pfSense firewall">Tweet</a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/"></g:plusone></span><span class="mr_social_sharing"><script type="IN/Share" data-url="http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://remcobressers.nl/2009/08/configuring-native-ipv6-pfsense/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

