<?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: Monitor your dynamic IP &amp; update IPtables when it changes</title>
	<atom:link href="http://www.axmx.net/2008/monitor-your-dynamic-ip-update-iptables-when-it-changes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.axmx.net/2008/monitor-your-dynamic-ip-update-iptables-when-it-changes/</link>
	<description>Just another online mini-empire</description>
	<lastBuildDate>Tue, 31 Aug 2010 02:45:57 +0100</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Mr. Blue</title>
		<link>http://www.axmx.net/2008/monitor-your-dynamic-ip-update-iptables-when-it-changes/comment-page-1/#comment-574</link>
		<dc:creator>Mr. Blue</dc:creator>
		<pubDate>Tue, 31 Aug 2010 02:45:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.axmx.net/?p=83#comment-574</guid>
		<description>Hey! thanks for the comment!!
So in this &quot;then&quot; section, what you would do is flush all your rules first, then apply your same rules, modified with the &#039;new&#039; IP address, like so:
&lt;code&gt;if [ &quot;$CURIP&quot; != &quot;$LASTIP&quot; ]
then
#add your iptables rule here to remove the old rules with the external dynamic ip in it, and insert the new IP using the $CURIP variable.
     &lt;strong&gt;$IPT -F&lt;/strong&gt; &lt;em&gt;(or whatever your preferred method is for flushing iptables)&lt;/em&gt;
     $IPT -A PREROUTING -t nat -d &lt;strong&gt;$CURIP&lt;/strong&gt; -p tcp –dport 8080 -j DNAT –to 192.168.0.201:8080
     $IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp –dport 8080 -d 192.168.0.201 -j MASQUERADE
     $IPT -A PREROUTING -t nat -d &lt;strong&gt;$CURIP&lt;/strong&gt; -p tcp –dport 2020 -j DNAT –to 192.168.0.201:2020
     $IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp –dport 2020 -d 192.168.0.201 -j MASQUERADE&lt;/code&gt;

Provided your iptables rules are correct as you want them, this &lt;strong&gt;&lt;em&gt;*should*&lt;/em&gt;&lt;/strong&gt; work. However bear in mind it&#039;s been about 3 years since I originally wrote this post :)</description>
		<content:encoded><![CDATA[<p>Hey! thanks for the comment!!<br />
So in this &#8220;then&#8221; section, what you would do is flush all your rules first, then apply your same rules, modified with the &#8216;new&#8217; IP address, like so:<br />
<code>if [ "$CURIP" != "$LASTIP" ]<br />
then<br />
#add your iptables rule here to remove the old rules with the external dynamic ip in it, and insert the new IP using the $CURIP variable.<br />
     <strong>$IPT -F</strong> <em>(or whatever your preferred method is for flushing iptables)</em><br />
     $IPT -A PREROUTING -t nat -d <strong>$CURIP</strong> -p tcp –dport 8080 -j DNAT –to 192.168.0.201:8080<br />
     $IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp –dport 8080 -d 192.168.0.201 -j MASQUERADE<br />
     $IPT -A PREROUTING -t nat -d <strong>$CURIP</strong> -p tcp –dport 2020 -j DNAT –to 192.168.0.201:2020<br />
     $IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp –dport 2020 -d 192.168.0.201 -j MASQUERADE</code></p>
<p>Provided your iptables rules are correct as you want them, this <strong><em>*should*</em></strong> work. However bear in mind it&#8217;s been about 3 years since I originally wrote this post <img src='http://www.axmx.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dana Schuett</title>
		<link>http://www.axmx.net/2008/monitor-your-dynamic-ip-update-iptables-when-it-changes/comment-page-1/#comment-573</link>
		<dc:creator>Dana Schuett</dc:creator>
		<pubDate>Tue, 31 Aug 2010 02:22:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.axmx.net/?p=83#comment-573</guid>
		<description>Hi, your iptables $CURIP update is exactly what I&#039;m looking for! I understand you entire script until it gets to the part on updated the iptable rules? Could you explain in more detail how this would work? I am just unclear how you actually get it into my iptables script.

WHAT I&#039;M UNSURE OF:
# update the iptables rules if the current IP is different from the last ip in /tmp/lastip
if [ &quot;$CURIP&quot; != &quot;$LASTIP&quot; ]
then
        #add your iptables rule here to remove the old rules with the external dynamic ip in it, and insert the new IP
        #using the $CURIP variable.

HERE IS WHERE I NEED THIS INJECTED INTO MY IPTABLES SCRIPT:

$IPT -A PREROUTING -t nat -d my.isp.ip.addr -p tcp --dport 8080 -j DNAT --to 192.168.0.201:8080
$IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp --dport 8080 -d 192.168.0.201 -j MASQUERADE
$IPT -A PREROUTING -t nat -d my.isp.ip.addr -p tcp --dport 2020 -j DNAT --to 192.168.0.201:2020
$IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp --dport 2020 -d 192.168.0.201 -j MASQUERADE


Thanks for your time,

Dana</description>
		<content:encoded><![CDATA[<p>Hi, your iptables $CURIP update is exactly what I&#8217;m looking for! I understand you entire script until it gets to the part on updated the iptable rules? Could you explain in more detail how this would work? I am just unclear how you actually get it into my iptables script.</p>
<p>WHAT I&#8217;M UNSURE OF:<br />
# update the iptables rules if the current IP is different from the last ip in /tmp/lastip<br />
if [ "$CURIP" != "$LASTIP" ]<br />
then<br />
        #add your iptables rule here to remove the old rules with the external dynamic ip in it, and insert the new IP<br />
        #using the $CURIP variable.</p>
<p>HERE IS WHERE I NEED THIS INJECTED INTO MY IPTABLES SCRIPT:</p>
<p>$IPT -A PREROUTING -t nat -d my.isp.ip.addr -p tcp &#8211;dport 8080 -j DNAT &#8211;to 192.168.0.201:8080<br />
$IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp &#8211;dport 8080 -d 192.168.0.201 -j MASQUERADE<br />
$IPT -A PREROUTING -t nat -d my.isp.ip.addr -p tcp &#8211;dport 2020 -j DNAT &#8211;to 192.168.0.201:2020<br />
$IPT -t nat -A POSTROUTING -s 192.168.0.0/24 -p tcp &#8211;dport 2020 -d 192.168.0.201 -j MASQUERADE</p>
<p>Thanks for your time,</p>
<p>Dana</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.743 seconds -->
