<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: iptables, port forwarding, and access from LAN-side</title>
	<atom:link href="http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/feed" rel="self" type="application/rss+xml" />
	<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side</link>
	<description>It's all spinning wheels and self-doubt until the first pot of coffee.</description>
	<pubDate>Tue, 02 Dec 2008 09:05:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7-almost-rc-9997</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bill Welch</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-48122</link>
		<dc:creator>Bill Welch</dc:creator>
		<pubDate>Wed, 08 Nov 2006 13:41:42 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-48122</guid>
		<description>&lt;p&gt;This web page has a working example.  I've included the link to give credit where it is due, and for context.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://forum.openwrt.org/viewtopic.php?id=4030" rel="nofollow"&gt;http://forum.openwrt.org/viewtopic.php?id=4030&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;iptables -t nat -A prerouting_rule -d x.x.x.x -p tcp --dport 80 -j DNAT --to 10.0.0.2
iptables -A forwarding_rule -p tcp --dport 80 -d 10.0.0.2 -j ACCEPT
iptables -t nat -A postrouting_rule -s 10.0.0.0/24 -p tcp --dport 80 -d 10.0.0.2 -j MASQUERADE&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>This web page has a working example.  I&#8217;ve included the link to give credit where it is due, and for context.</p>
<p><a href="http://forum.openwrt.org/viewtopic.php?id=4030" rel="nofollow">http://forum.openwrt.org/viewtopic.php?id=4030</a></p>
<pre>iptables -t nat -A prerouting_rule -d x.x.x.x -p tcp --dport 80 -j DNAT --to 10.0.0.2
iptables -A forwarding_rule -p tcp --dport 80 -d 10.0.0.2 -j ACCEPT
iptables -t nat -A postrouting_rule -s 10.0.0.0/24 -p tcp --dport 80 -d 10.0.0.2 -j MASQUERADE</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: nystark</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-11262</link>
		<dc:creator>nystark</dc:creator>
		<pubDate>Tue, 23 May 2006 17:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-11262</guid>
		<description>&lt;p&gt;i had the same issue after upgrading from rc4, the easy solution is to add a rule for your local subnet and have it forward to your destination.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>i had the same issue after upgrading from rc4, the easy solution is to add a rule for your local subnet and have it forward to your destination.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 0r</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-11146</link>
		<dc:creator>0r</dc:creator>
		<pubDate>Fri, 19 May 2006 09:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-11146</guid>
		<description>&lt;p&gt;iptables -t nat -A PREROUTING -p tcp -d 15.45.23.67 --dport 80 -j DNAT --to-destination 192.168.1.1-192.168.1.10&lt;/p&gt;

&lt;p&gt;iptables -t nat -A POSTROUTING -p tcp --dst $HTTP&lt;em&gt;IP --dport 80 -j SNAT --to-source $LAN&lt;/em&gt;IP&lt;/p&gt;

&lt;p&gt;iptables -t nat -A OUTPUT --dst $INET&lt;em&gt;IP -p tcp --dport 80 -j DNAT --to-destination $HTTP&lt;/em&gt;IP&lt;/p&gt;

&lt;p&gt;Check http://iptables-tutorial.frozentux.net/chunkyhtml/x4013.html for explanations of the lines above. Another good reference is http://tldp.org/HOWTO/IP-Masquerade-HOWTO/index.html (and http://www.openbsd.org/faq/pf/rdr.html if you are on BSD). The DNS solution seems better since it won't harm your logging.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>iptables -t nat -A PREROUTING -p tcp -d 15.45.23.67 &#8211;dport 80 -j DNAT &#8211;to-destination 192.168.1.1-192.168.1.10</p>
<p>iptables -t nat -A POSTROUTING -p tcp &#8211;dst $HTTP<em>IP &#8211;dport 80 -j SNAT &#8211;to-source $LAN</em>IP</p>
<p>iptables -t nat -A OUTPUT &#8211;dst $INET<em>IP -p tcp &#8211;dport 80 -j DNAT &#8211;to-destination $HTTP</em>IP</p>
<p>Check <a href="http://iptables-tutorial.frozentux.net/chunkyhtml/x4013.html" rel="nofollow">http://iptables-tutorial.frozentux.net/chunkyhtml/x4013.html</a> for explanations of the lines above. Another good reference is <a href="http://tldp.org/HOWTO/IP-Masquerade-HOWTO/index.html" rel="nofollow">http://tldp.org/HOWTO/IP-Masquerade-HOWTO/index.html</a> (and <a href="http://www.openbsd.org/faq/pf/rdr.html" rel="nofollow">http://www.openbsd.org/faq/pf/rdr.html</a> if you are on BSD). The DNS solution seems better since it won&#8217;t harm your logging.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heretic</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-11100</link>
		<dc:creator>Heretic</dc:creator>
		<pubDate>Wed, 17 May 2006 03:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-11100</guid>
		<description>&lt;p&gt;Feel like a moron no more :o)&lt;/p&gt;

&lt;p&gt;I believe what you are looking for is something like the following two rules:&lt;/p&gt;

&lt;p&gt;1.)  $IPTABLES -A FORWARD -i $EXTIF -o $INTIF -p tcp --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT&lt;/p&gt;

&lt;p&gt;2.)  $IPTABLES -A FORWARD -i $EXTIF -o $INTIF -p tcp --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT&lt;/p&gt;

&lt;p&gt;I hope that helps!&lt;/p&gt;

&lt;p&gt;Heretic&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Feel like a moron no more :o)</p>
<p>I believe what you are looking for is something like the following two rules:</p>
<p>1.)  $IPTABLES -A FORWARD -i $EXTIF -o $INTIF -p tcp &#8211;dport 80 -m state &#8211;state NEW,ESTABLISHED,RELATED -j ACCEPT</p>
<p>2.)  $IPTABLES -A FORWARD -i $EXTIF -o $INTIF -p tcp &#8211;dport 80 -m state &#8211;state NEW,ESTABLISHED,RELATED -j ACCEPT</p>
<p>I hope that helps!</p>
<p>Heretic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: l.m.orchard</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10808</link>
		<dc:creator>l.m.orchard</dc:creator>
		<pubDate>Wed, 10 May 2006 16:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10808</guid>
		<description>&lt;p&gt;Oh, holy hell.  I can't figure out the proper iptables arrangement - which still bugs me - but I did discover that my router's running &lt;a href="http://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html" rel="nofollow"&gt;dnsmasq&lt;/a&gt; and that the following line in &lt;code&gt;/etc/dnsmasq.conf&lt;/code&gt; did the trick:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;address=/foo.dyndns.org/192.168.123.123
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Still feeling like a moron.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Oh, holy hell.  I can&#8217;t figure out the proper iptables arrangement - which still bugs me - but I did discover that my router&#8217;s running <a href="http://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html" rel="nofollow">dnsmasq</a> and that the following line in <code>/etc/dnsmasq.conf</code> did the trick:</p>
<pre><code>address=/foo.dyndns.org/192.168.123.123
</code></pre>
<p>Still feeling like a moron.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: l.m.orchard</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10807</link>
		<dc:creator>l.m.orchard</dc:creator>
		<pubDate>Wed, 10 May 2006 15:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10807</guid>
		<description>&lt;p&gt;Okay, addendum summary:  I'm already using DynDNS to point at my home address, my external IP.  I've used a DNS cache that substituted a LAN IP for that domain name for LAN clients in the past and didn't like it.  Up until this week, my firewall rules allowed port 80 on my external IP to respond to traffic from the WAN and the LAN interfaces.  But now, those rules are gone and I don't remember what the magic invocation was in iptables.&lt;/p&gt;

&lt;p&gt;Bah, I'll probably just end up going back to a DNS cache.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Okay, addendum summary:  I&#8217;m already using DynDNS to point at my home address, my external IP.  I&#8217;ve used a DNS cache that substituted a LAN IP for that domain name for LAN clients in the past and didn&#8217;t like it.  Up until this week, my firewall rules allowed port 80 on my external IP to respond to traffic from the WAN and the LAN interfaces.  But now, those rules are gone and I don&#8217;t remember what the magic invocation was in iptables.</p>
<p>Bah, I&#8217;ll probably just end up going back to a DNS cache.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevan Emmott</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10806</link>
		<dc:creator>Kevan Emmott</dc:creator>
		<pubDate>Wed, 10 May 2006 15:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10806</guid>
		<description>&lt;p&gt;OpenWRT may offer this, but this is what I do with &lt;a href="http://m0n0.ch/wall/" rel="nofollow"&gt;m0n0wall&lt;/a&gt;, which I have running on one of those little dedicated &lt;a href="http://www.pcengines.ch/wrap.htm" rel="nofollow"&gt;WRAP&lt;/a&gt; boxes - it can run a &lt;a href="http://img.m0n0.ch/screens/services_dnsmasq.png" rel="nofollow"&gt;DNS forwarder&lt;/a&gt; for the internal boxes that are accessing the world. In other words, it runs as a DNS cache from whatever your external DNS is, and then can inject any custom entries you want. Then configure DHCP or any internal static IP boxes to point at the router as a DNS server. Then you can setup overriding rules for any DNS entries that refer to your home external IP.&lt;/p&gt;

&lt;p&gt;You also stated you access it via your "external IP" - are you not using a dynamic DNS service like DynDNS to give your home an external domain? You could even then use a real DNS provider to make a nicer domain (say a subdomain of your website) be a CNAME pointing at the DynDNS entry. m0n0wall and many other routers also have &lt;a href="http://img.m0n0.ch/screens/services_dyndns.png" rel="nofollow"&gt;DynDNS clients&lt;/a&gt; built in. Who needs static IPs? You certainly don't if all you need is web and ssh access.&lt;/p&gt;

&lt;p&gt;So for example, I may have an internal web server running at 192.168.1.10, with my external IP being 1.2.3.4. So I have home.cafgood.com as a CNAME pointing at cafgood.dyndns.com which gets automatically set to resolve to my external home IP (1.2.3.4). On my router, I then say home.cafgood.com equals the internal IP (192.168.1.10). From the outside, I would hit real DNS servers, get CNAME-pointed to DynDNS servers, which would point me at my external IP, and NAT points at the web server. From the inside, the overridden DNS forwarder would just point any internal request right at the web server.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>OpenWRT may offer this, but this is what I do with <a href="http://m0n0.ch/wall/" rel="nofollow">m0n0wall</a>, which I have running on one of those little dedicated <a href="http://www.pcengines.ch/wrap.htm" rel="nofollow">WRAP</a> boxes - it can run a <a href="http://img.m0n0.ch/screens/services_dnsmasq.png" rel="nofollow">DNS forwarder</a> for the internal boxes that are accessing the world. In other words, it runs as a DNS cache from whatever your external DNS is, and then can inject any custom entries you want. Then configure DHCP or any internal static IP boxes to point at the router as a DNS server. Then you can setup overriding rules for any DNS entries that refer to your home external IP.</p>
<p>You also stated you access it via your &#8220;external IP&#8221; - are you not using a dynamic DNS service like DynDNS to give your home an external domain? You could even then use a real DNS provider to make a nicer domain (say a subdomain of your website) be a CNAME pointing at the DynDNS entry. m0n0wall and many other routers also have <a href="http://img.m0n0.ch/screens/services_dyndns.png" rel="nofollow">DynDNS clients</a> built in. Who needs static IPs? You certainly don&#8217;t if all you need is web and ssh access.</p>
<p>So for example, I may have an internal web server running at 192.168.1.10, with my external IP being 1.2.3.4. So I have home.cafgood.com as a CNAME pointing at cafgood.dyndns.com which gets automatically set to resolve to my external home IP (1.2.3.4). On my router, I then say home.cafgood.com equals the internal IP (192.168.1.10). From the outside, I would hit real DNS servers, get CNAME-pointed to DynDNS servers, which would point me at my external IP, and NAT points at the web server. From the inside, the overridden DNS forwarder would just point any internal request right at the web server.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Prodoehl</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10804</link>
		<dc:creator>Pete Prodoehl</dc:creator>
		<pubDate>Wed, 10 May 2006 14:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10804</guid>
		<description>&lt;p&gt;This is the reason I've got a wiki on my home network I store all the little notes and config stuff in. It's on the Linux box I never tinker with, so I'm sure not to wipe it out. (I also do some minimal backups as well in case of trouble.)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This is the reason I&#8217;ve got a wiki on my home network I store all the little notes and config stuff in. It&#8217;s on the Linux box I never tinker with, so I&#8217;m sure not to wipe it out. (I also do some minimal backups as well in case of trouble.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: l.m.orchard</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10800</link>
		<dc:creator>l.m.orchard</dc:creator>
		<pubDate>Wed, 10 May 2006 10:48:51 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10800</guid>
		<description>&lt;p&gt;fluffy:  Eh, OpenWRT lets me meddle, first of all (see &lt;a href="http://decafbad.com/blog/2006/05/03/hacking-is-my-world-of-warcraft" rel="nofollow"&gt;this post&lt;/a&gt;).. But, second, it's got some traffic shaping stuff I've been learning about, can run a VPN connection, and let's me SSH in to a screen session to check on some other machines at home.  Between this and my NSLU2, I don't have a PC home linux server anymore.  (Of course, I haven't checked out the factory firmware in awhile, so they may have made some updates I haven't seen.)&lt;/p&gt;

&lt;p&gt;Stuart: I did just that at one point, by running a DNS proxy on the home LAN that gave an internal IP answer for the equivalent of home.decafbad.com - while the rest of the world saw the WAN address.  I think I did it with tinydns, but I seem to remember it was a pain in the butt for some reason.  I should check it out again.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>fluffy:  Eh, OpenWRT lets me meddle, first of all (see <a href="http://decafbad.com/blog/2006/05/03/hacking-is-my-world-of-warcraft" rel="nofollow">this post</a>).. But, second, it&#8217;s got some traffic shaping stuff I&#8217;ve been learning about, can run a VPN connection, and let&#8217;s me SSH in to a screen session to check on some other machines at home.  Between this and my NSLU2, I don&#8217;t have a PC home linux server anymore.  (Of course, I haven&#8217;t checked out the factory firmware in awhile, so they may have made some updates I haven&#8217;t seen.)</p>
<p>Stuart: I did just that at one point, by running a DNS proxy on the home LAN that gave an internal IP answer for the equivalent of home.decafbad.com - while the rest of the world saw the WAN address.  I think I did it with tinydns, but I seem to remember it was a pain in the butt for some reason.  I should check it out again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Langridge</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10798</link>
		<dc:creator>Stuart Langridge</dc:creator>
		<pubDate>Wed, 10 May 2006 09:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10798</guid>
		<description>&lt;p&gt;Just in case I'm a bit dim, why would you not refer to the machine by name? I appreciate the cleverness with IPs was a nice thing to do, but wouldn't it be easier to just call it home.decafbad.com wherever you are (and have that resolve to the internal IP address of the box inside the network and the external address outside)?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Just in case I&#8217;m a bit dim, why would you not refer to the machine by name? I appreciate the cleverness with IPs was a nice thing to do, but wouldn&#8217;t it be easier to just call it home.decafbad.com wherever you are (and have that resolve to the internal IP address of the box inside the network and the external address outside)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fluffy</title>
		<link>http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side/comment-page-1#comment-10795</link>
		<dc:creator>fluffy</dc:creator>
		<pubDate>Wed, 10 May 2006 03:59:14 +0000</pubDate>
		<guid isPermaLink="false">http://decafbad.com/blog/2006/05/09/iptables-port-forwarding-and-access-from-lan-side#comment-10795</guid>
		<description>&lt;p&gt;What does OpenWRT get you that the stock factory firmware doesn't?  Personally I've been very happy with the official firmware and it's nice easy web-based configuration which also happens to support everything I need out of a router (port forwarding, access control, QoS, etc.)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>What does OpenWRT get you that the stock factory firmware doesn&#8217;t?  Personally I&#8217;ve been very happy with the official firmware and it&#8217;s nice easy web-based configuration which also happens to support everything I need out of a router (port forwarding, access control, QoS, etc.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
