<?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; Networking</title>
	<atom:link href="http://remcobressers.nl/category/networking/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>IPv6 on a Cisco 877 CPE device is quite simple</title>
		<link>http://remcobressers.nl/2010/09/ipv6-cisco-877-cpe-device-simple/</link>
		<comments>http://remcobressers.nl/2010/09/ipv6-cisco-877-cpe-device-simple/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 21:06:48 +0000</pubDate>
		<dc:creator>Remco Bressers</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://remcobressers.nl/?p=176</guid>
		<description><![CDATA[Working with routers and switches everyday on my daytime job it is certainly interesting when it comes to configuring IPv6 on my homebase in Boxtel / The Netherlands. On my job i implemented ISP-wide IPv6 on services we deliver like fiber, DSL, colocation and other stuff and now it&#8217;s time to do what every geek [...]]]></description>
			<content:encoded><![CDATA[<p>Working with routers and switches everyday on my <a href="http://signet.nl">daytime job</a> it is certainly interesting when it comes to configuring IPv6 on my homebase in Boxtel / The Netherlands. On my job i implemented ISP-wide IPv6 on services we deliver like fiber, DSL, colocation and other stuff and now it&#8217;s time to do what every geek on this planet should do. Get your sweet IPv6 /48 block and configure the darn thing <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>At home i use a Cisco 877 ADSL router with the advanced-ip-services IOS software on it. While the Cisco 800-series routers are quite good, it&#8217;s insane that Cisco wants an extra $$$ for the IOS software with IPv6. It definitely should be a default in all CPE devices. On the other hand, Cisco is one of the few with a very nice IPv6 implementation ready whereas other (Chinese, Taiwanese&#8230;) vendors only have half of it or none at all. It&#8217;s pathetic!</p>
<p>If you want more information on IPv6 i can really recommend you the book by Iljitsch van Beijnum named <a href="http://runningipv6.net">Running IPv6</a> which contains all the gory details on every aspect IPv6 has to offer. After reading the book you will notice that IPv6 is definitely not rocket science and it&#8217;s very easy to implement.</p>
<p>This is what i want on an IPv6 setup :</p>
<ul>
<li>A /48 block of global IPv6 addresses</li>
<li>Router-advertisements on the LAN so i don&#8217;t have to configure them by hand</li>
<li>A firewall on my router</li>
</ul>
<p>A firewall? Yes! There&#8217;s no NAT anymore with IPv6, so every PC on your LAN gets a public routable IPv6 address which is great but without a decent firewall it&#8217;s a potential security risk. Especially because of the different (crappy) firewall implementations on various operating systems (Windows, Mac OS X) we really want this to be done on the router just like a NAT router blocks all incoming and passes all outgoing. I know that you cannot compare a NAT router with a firewall but for the sake of simplicity this is the way it&#8217;s going to be.</p>
<p>On the Cisco i have an ADSL line, configured with PPP-over-ATM. I cannot do native IPv6 on the thing right now because i have been pretty lazy on reconfiguring my own DSL line <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . For now, i&#8217;m tunneling IPv6 through a GRE tunnel over IPv4 to a tunnel endpoint at my job premises.</p>
<p>The actual Cisco configuration for the network and routing connections :</p>
<p> </p>
<pre>ipv6 unicast-routing
</pre>
<p>This is mandatory! Without this, the Cisco will not do any routing on IPv6</p>
<pre>ipv6 cef
interface tunnel1
 no ip address
 ipv6 address 2001:4fff:5:1::1:1/126
 ipv6 enable
 tunnel source
 tunnel destination
!
interface Vlan1
 ipv6 address 2001:4fff:4::1/64
 ipv6 enable
 ipv6 nd prefix 2001:4fff:4::/64
 ipv6 nd advertisement-interval
 ipv6 nd ra interval 4
!
</pre>
<p>The latter command (ipv6 nd ra interval 4) fixed an annoying problem i had with one of the Windoof Vista hosts on the network.</p>
<p>Alright! We have a running IPv6 configuration with router-advertisements (ipv6 nd) sending to my clients. This way all my clients will have a working IPv6 configuration ready to use.</p>
<p>BUT.. You&#8217;re not finished just yet..</p>
<p>Do not forget the firewall step</p>
<pre>ipv6 inspect name traffic tcp
ipv6 inspect name traffic udp
ipv6 inspect name traffic ftp
ipv6 inspect name traffic icmp
!
interface tunnel1
 ipv6 traffic-filter tu1-in in
 ipv6 traffic-filter tu1-out out
!
ipv6 access-list tu1-in
 permit icmp any any echo-request
 permit icmp any any echo-reply
 permit tcp 2001:4fff::/32 any eq 22
 evaluate reflectout
 deny ipv6 any any log-input
!
ipv6 access-list tu1-out
 permit icmp any any echo-reply
 permit icmp any any echo-request
 permit tcp any any reflect reflectout
 permit udp any any reflect reflectout
 deny ipv6 any any log-input
!
</pre>
<p>As you can see, this is a stateful firewall configuration on an IOS device. The reflect rule creates the state and the evaluate (in tu1-in) tries to find a match on the reflect rule. For this to work i found out i needed the ipv6 inspect rules.</p>
<p>And that&#8217;s about it! If you have real native-IPv6 on your ethernet router this will even be more easy.</p>
<p>That&#8217;s it for today. If you have any comments or things to add, please leave a comment. Awareness for IPv6 is key at this moment!</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%2F2010%2F09%2Fipv6-cisco-877-cpe-device-simple%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/2010/09/ipv6-cisco-877-cpe-device-simple/" data-text="IPv6 on a Cisco 877 CPE device is quite simple">Tweet</a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://remcobressers.nl/2010/09/ipv6-cisco-877-cpe-device-simple/"></g:plusone></span><span class="mr_social_sharing"><script type="IN/Share" data-url="http://remcobressers.nl/2010/09/ipv6-cisco-877-cpe-device-simple/"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://remcobressers.nl/2010/09/ipv6-cisco-877-cpe-device-simple/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>
		<item>
		<title>Configuring NAT on Juniper J-series</title>
		<link>http://remcobressers.nl/2008/07/configuring-nat-on-juniper-j-series/</link>
		<comments>http://remcobressers.nl/2008/07/configuring-nat-on-juniper-j-series/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 13:29:43 +0000</pubDate>
		<dc:creator>Remco Bressers</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://remcobressers.nl/?p=9</guid>
		<description><![CDATA[In the past, i configured a lot of nifty things on Juniper M-series routers like BGP, OSPF and all sorts of routing stuff. Back to basics (NAT) would have to be a piece of cake . But&#8230; Configuring NAT on a J-series Juniper box is pretty well documented in the Juniper documentation. I mean.. VERY [...]]]></description>
			<content:encoded><![CDATA[<p>In the past, i configured a lot of nifty things on Juniper M-series routers like BGP, OSPF and all sorts of routing stuff. Back to basics (NAT) would have to be a piece of cake <img src='http://remcobressers.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>But&#8230;</p>
<p>Configuring NAT on a <a href="http://www.juniper.net/products_and_services/j_series_services_routers/index.html">J-series</a> <a href="http://www.juniper.net">Juniper</a> box is pretty well documented in the Juniper documentation. I mean.. VERY well documented in a way nobody seems to get the whole point about NAT&#8217;ting on the box.</p>
<p>The most straightforward NAT configuration is never being discussed anywhere in the documentation and that makes it pretty hard to get it to work. After some braincracks, i finally managed to get it to work in a way i want it.</p>
<p>The usual CPE setup applies here, so we have one single public IP address on the outside and an <a href="http://www.apps.ietf.org/rfc/rfc1918.html">RFC1918</a> 192.168.1.0/24 subnet on the inside interface. Our default gateway resides at 217.1.10.254. Our mailserver is at 192.168.1.254, doing only SMTP.</p>
<div class="imageframe" style="width: 374px;"><a title="NAT the easy way" rel="lightbox[pics9]" href="http://remcobressers.nl/wp-content/uploads/2008/07/nat.png"><img class="attachment wp-att-10" src="http://remcobressers.nl/wp-content/uploads/2008/07/nat.png" alt="NAT the easy way" width="374" height="343" /></a></p>
<div class="imagecaption"><em>&#8220;NAT the easy way&#8221;</em></p>
<p><em></em></p>
</div>
</div>
<div class="imagecaption">Alright, now we know how to setup the network, let&#8217;s configure the J-box. Forget the J-web interface as we&#8217;re not going to use it. JunOS CLI it is.<br />
Please note that <strong>i&#8217;m not running JunOS enhanced services</strong> in this example. With ES it should be a little more straightforward and easier to configure, but i just wanted it to run on the plain vanilla JunOS 9.1</div>
<div class="imagecaption">Log in to the box, and start configuring the default stuff:</div>
<pre>remco@router&gt; configure
remco@router# set system host-name myrouter
remco@router# set system domain-name remcobressers.nl
remco@router# set root-authentication plain-text-password

    Enter your password here for root access.

remco@router# set domain-search remcobressers.nl
remco@router# set time-zone Europe/Amsterdam
remco@router# set location country-code nl
remco@router# set system name-server 217.1.10.10 217.1.10.11
remco@router# set system login user remco uid 2000 class super-user authentication plain-text-password

    Enter your user password to enter the CLI.

remco@router# set system services ssh</pre>
<p>Alright. We&#8217;re all set. Now let&#8217;s configure the interfaces. Let&#8217;s say ge-0/0/0 is our outside WAN interface and ge-0/0/1 is the inside LAN interface.</p>
<pre>remco@router# edit interfaces ge-0/0/0
[edit interfaces ge-0/0/0]
remco@router# set description "WAN"
remco@router# set unit 0 family inet address 217.1.10.1/24

remco@router# top
[edit]
remco@router# edit interfaces ge-0/0/1
[edit interfaces ge-0/0/1]
remco@router# set description "LAN"
remco@router# set unit 0 family inet address 192.168.1.1/24
remco@router# top
[edit]
remco@router# set routing-options static route 0.0.0.0/0 next-hop 217.1.10.1</pre>
<p>Ok. Our basic setup is completed. Let&#8217;s configure NAT. We have an internal server at 192.168.1.254 which does SMTP, so we need to configure 2 things:</p>
<ul>
<li>NAT from LAN to the WAN (overload)</li>
<li>NAT port forwarding from WAN to 192.168.1.254 SMTP on the LAN</li>
</ul>
<p>Shouldn&#8217;t be to difficult.</p>
<pre>remco@router# edit services service-set wan-service-set
[edit services service-set wan-service-set]
remco@router# set nat-rules nat-outgoing
remco@router# set nat-rules nat-incoming
remco@router# set interface-service service-interface sp-0/0/0.0
remco@router# up
[edit services]
remco@router# edit nat
[edit services nat]
remco@router# set pool nat-pool address-range low 217.1.10.1 high 217.1.10.1
remco@router# set pool nat-pool port automatic
remco@router# edit rule nat-outgoing
[edit services nat rule nat-outgoing]
remco@router# set match-direction output
remco@router# set term 1 then translated source-pool nat-pool
remco@router# set term 1 then translated translation-type source dynamic
remco@router# up
[edit services nat]
remco@router# edit rule nat-incoming
[edit services nat rule nat-incoming]
remco@router# set match-direction input
remco@router# set term smtp from destination-address 217.1.10.1/32
remco@router# set term smtp from applications junos-smtp
remco@router# set term smtp then translated destination-prefix 192.168.1.254/32
remco@router# set term smtp then translated translation-type destination static
remco@router# set term other from destination-address 217.1.10.1/32
remco@router# set term other then no-translation</pre>
<p>Alright. This looks like a little confusing. It all comes down to the following.</p>
<ol>
<li>Create a service-set named &#8220;wan-service-set&#8221;, which holds our nat rules &#8220;nat-outgoing&#8221; and &#8220;nat-incoming&#8221;. Services needs a virtual services interface. In this case, the default is sp-0/0/0.0.</li>
<li>In the NAT configuration, we create a pool, which holds one single public IP address (217.1.10.1). The ports are dynamically assigned.</li>
<li>Our outgoing NAT rule is used to translate our internal traffic to the Internet on the public address. Our source pool is the pool we just created.</li>
<li>Our incoming NAT rule is used to translate incoming SMTP traffic to our internal SMTP server at 192.168.1.254.</li>
<li>We use the application &#8220;helper&#8221; junos-smtp instead of creating our own application. The result is the same.</li>
<li>Other incoming traffic won&#8217;t be translated (this is important to include).</li>
</ol>
<p>We now need to configure the service-set &#8220;wan-service-set&#8221; to the interface we do the translation on, which is the outside interface ge-0/0/0.</p>
<pre>remco@router# top
[edit]
remco@router# edit interfaces ge-0/0/0 unit 0 family inet
[edit interfaces ge-0/0/0 unit 0 family inet]
remco@router# set service input service-set wan-service-set
remco@router# set service output service-set wan-service-set</pre>
<p>Alright, that&#8217;s about it. You can commit the configuration now with the &#8220;commit&#8221; command.<br />
Your configuration will now look like this :</p>
<p>remco@router# top<br />
[edit]<br />
remco@router# show</p>
<pre>## Last changed: 2008-07-17 21:13:49 CEST
version 9.1R1.8;
system {
    host-name myrouter;
    domain-name remcobressers.nl;
    domain-search remcobressers.nl;
    time-zone Europe/Amsterdam;
    location country-code nl;
    root-authentication {
        encrypted-password "**************"; ## SECRET-DATA
    }
    name-server {
        217.1.10.10;
        217.1.10.11;
    }
    login {
        user remco {
            uid 2000;
            class super-user;
            authentication {
                encrypted-password "***********"; ## SECRET-DATA
            }
        }
    }
    services {
        ssh {
        }
    }
}
interfaces {
    ge-0/0/0 {
        description "WAN";
        unit 0 {
            family inet {
                service {
                    input {
                        service-set wan-service-set;
                    }
                    output {
                        service-set wan-service-set;
                    }
                }
                address 217.1.10.1/24;
            }
        }
    }
    sp-0/0/0 {
        unit 0 {
            family inet;
        }
    }
    ge-0/0/1 {
        description "LAN";
        unit 0 {
            family inet {
                address 192.168.1.1/24;
            }
        }
    }
}
routing-options {
    static {
        route 0.0.0.0/0 next-hop 217.1.10.254;
    }
}
services {
    service-set wan-service-set {
        nat-rules nat-outgoing;
        nat-rules nat-incoming;
        interface-service {
            service-interface sp-0/0/0.0;
        }
    }
    nat {
        pool nat-pool {
            address-range low 217.1.10.1 high 217.1.10.1;
            port automatic;
        }
        rule nat-outgoing {
            match-direction output;
            term 1 {
                then {
                    translated {
                        source-pool nat-pool;
                        translation-type {
                            source dynamic;
                        }
                    }
                }
            }
        }
        rule nat-incoming {
            match-direction input;
            term smtp {
                from {
                    destination-address {
                        217.1.10.1/32;
                    }
                    applications junos-smtp;
                }
                then {
                    translated {
                        destination-prefix 192.168.1.254/32;
                        translation-type {
                            destination static;
                        }
                    }
                }
            }
            term other {
                from {
                    destination-address {
                        217.1.10.1/32;
                    }
                }
                then {
                    no-translation;
                }
            }
        }
    }
}</pre>

				<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%2F2008%2F07%2Fconfiguring-nat-on-juniper-j-series%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/2008/07/configuring-nat-on-juniper-j-series/" data-text="Configuring NAT on Juniper J-series">Tweet</a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://remcobressers.nl/2008/07/configuring-nat-on-juniper-j-series/"></g:plusone></span><span class="mr_social_sharing"><script type="IN/Share" data-url="http://remcobressers.nl/2008/07/configuring-nat-on-juniper-j-series/"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://remcobressers.nl/2008/07/configuring-nat-on-juniper-j-series/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

