From: "Indunil Jayasooriya" Date: Tue, 25 Sep 2007 08:35:40 +0000 Subject: Re: [LARTC] DNAT PREROUTING issue with IPTABLES Message-Id: <7ed6b0aa0709250123m1fec4331nb34f28dc8e2da1be@mail.gmail.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============1683718956==" List-Id: References: <7ed6b0aa0709242228u211036fdoa33ffa47519ecb2e@mail.gmail.com> In-Reply-To: <7ed6b0aa0709242228u211036fdoa33ffa47519ecb2e@mail.gmail.com> To: lartc@vger.kernel.org --===============1683718956== Content-Type: multipart/alternative; boundary="----=_Part_58779_31392988.1190708620764" ------=_Part_58779_31392988.1190708620764 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/25/07, Aleksander Kamenik wrote: > > Indunil Jayasooriya wrote: > > FIRST firewall (its internet ip address - 1.2.3.4/29 > > ) I have addes below rule. > > > > iptables -t nat -A PREROUTING -p tcp -i eth0 -d 1.2.3.4 > > --dport 25 -j DNAT --to-destination 2.3.4.5:25 > > > > That should forward port 25 to SECOND firewall. in SECOND firewall, I > > have added 2 below rules. > > > > iptables -t nat -A PREROUTING -p tcp -i eth0 -d 2.3.4.5 > > --dport 25 -j DNAT --to-destination 192.168.100.3:25 > > > > > > iptables -A FORWARD -p tcp -d 192.168.100.3 > > --dport 25 -m state --state NEW -j ACCEPT > > First run tcpdump* or the like on the smtp box to see that incoming > packets arrive. If they don't, see if they arrive on 2.3.4.5 etc. > > If they arrive at the destination see how much they go back (tcpdump on > the firewall boxes). > > Btw, assuming both of your firewall boxes have similar iptables > rulesets, shouldn't the first one also have a -t filter -A FORWARD ... > -j ACCEPT rule? No filter rule has been speciied. Make sure you also have the ESTABLISHED,RELATED -j > ACCEPT rules. I have not added it to prerouting chain. I added just now. > Forward, input and output chains have it. And have you made sure that the smtp box accepts connections from > anywhere? it is behing my second firewall. it is @ DMZ ZONE. > YES, It accpets connections from any where. Let's say, If I telnet to port 25 as bellow, telnet 2.3.4.5 25 it accepts, It works. Now what I need is that I want to telnet to first firewall, then, it will forward to second firewall, second firewall will forward to actual mail server. Is your MTA listening on the external interface? eth0 is the internet ip of firewall. eth1 is connected to mail server. > > * - tcpdump -i eth0 port 25 > > Regards, > > -- > Aleksander Kamenik > system administrator > +372 6659 649 > aleksander@krediidiinfo.ee > > Krediidiinfo AS > http://www.krediidiinfo.ee/ > _______________________________________________ > LARTC mailing list > LARTC@mailman.ds9a.nl > http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc > -- Thank you Indunil Jayasooriya ------=_Part_58779_31392988.1190708620764 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 9/25/07, Aleksander Kamenik <aleksander@krediidiinfo.ee> wrote:
Indunil Jayasooriya wrote:
> FIRST firewall (its internet ip address - 1.2.3.4/29
> <http://1.2.3.4/29>) I have addes below rule.
>
> iptables -t nat -A PREROUTING -p tcp -i eth0 -d 1.2.3.4 <http://1.2.3.4>
> --dport 25 -j DNAT --to-destination 2.3.4.5:25 <http://2.3.4.5:25>
>
> That should forward port 25 to SECOND firewall. in SECOND firewall, I
> have added 2 below rules.
>
> iptables -t nat -A PREROUTING -p tcp -i eth0 -d 2.3.4.5 <http://2.3.4.5>
> --dport 25 -j DNAT --to-destination 192.168.100.3:25
> < http://192.168.100.3:25>
>
> iptables -A FORWARD -p tcp -d 192.168.100.3 <http://192.168.100.3>
> --dport 25 -m state --state NEW -j ACCEPT

First run tcpdump* or the like on the smtp box to see that incoming
packets arrive. If they don't, see if they arrive on 2.3.4.5 etc.

If they arrive at the destination see how much they go back (tcpdump on
the firewall boxes).

Btw, assuming both of your firewall boxes have similar iptables
rulesets, shouldn't the first one also have a -t filter -A FORWARD ...
-j ACCEPT rule?
No filter rule has been speciied.
 

Make sure you also have the ESTABLISHED,RELATED -j
ACCEPT rules. I have not added it to prerouting chain. I added just now. Forward, input and output  chains have it.

 
And have you made sure that the smtp box accepts connections from
anywhere? it is behing my second firewall. it is @ DMZ ZONE.
YES, It accpets connections from any where. Let's say, If I telnet to port 25 as bellow,

telnet 2.3.4.5 25

it accepts, It works.

Now what I need is that  I want to telnet to first firewall, then, it will forward to second firewall, second firewall will forward to actual mail server.


 Is your MTA listening on the external interface?

eth0 is the internet ip of firewall. eth1 is connected to mail server.

* - tcpdump -i eth0 port 25

Regards,

--
Aleksander Kamenik
system administrator
+372 6659 649
aleksander@krediidiinfo.ee

Krediidiinfo AS
http://www.krediidiinfo.ee/
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc



--
Thank you
Indunil Jayasooriya
------=_Part_58779_31392988.1190708620764-- --===============1683718956== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc --===============1683718956==--