Skip to contentSkip to conversation

SMTP HTTP port allow

DISCUSSION ads nat 4 participants 5 messages Aug 27, 2003

lore
Share & tools
lore

ads nat

author
#0 lore raw

I am implimenting iptables for first time.
I want to allow all my LAN users to send emails to SMTP (port no. 25) all destination with following code. :

***
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT
***

I also want to allow LAN users having ip 192.168.0.42 192.168.0.23 to upload contents to webserver on ip 207.106.22.35 (outside of LAN) with following code.

***
iptables -A FORWARD -p tcp -s 192.168.0.42 192.168.0.23 -d 207.106.22.35 --dport 80 -j ACCEPT
***

I would loke know whether It works or not.
Tell me whether my code is O.K. also where can i check logs. Thanks

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

#1 lore raw

You have not used MASQUERADE in your POSTROUTING rules or haven't showed it..

iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.42 -d 207.106.22.35 --dport 80 -j MASQUERADE
iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.23 -d 207.106.22.35 --dport 80 -j MASQUERADE

without the rules above, the 192.168.0.XX packets leave the network out into the internet and eventually get dropped by some ISP...

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of ads nat
Sent: Wednesday, August 27, 2003 4:53 PM
To: [email protected]
Subject: SMTP HTTP port allow

I am implimenting iptables for first time.
I want to allow all my LAN users to send emails to SMTP (port no. 25) all destination with following code. :

***
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT

***

I also want to allow LAN users having ip 192.168.0.42 192.168.0.23 to upload contents to webserver on ip 207.106.22.35 (outside of LAN) with following code.

***
iptables -A FORWARD -p tcp -s 192.168.0.42 192.168.0.23 -d 207.106.22.35 --dport 80 -j ACCEPT
***

I would loke know whether It works or not.
Tell me whether my code is O.K. also where can i check logs. Thanks

----------------------------------------------------------------------------
----
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

author
#2 lore raw

My code has become as follows :

******
iptables -A POSTROUTING -t nat -p tcp --dport 25 -j MASQUERADE

iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.42 -d 207.106.22.35 --dport 21 -j MASQUERADE iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.23 -d 207.106.22.35 --dport 21 -j MASQUERADE

iptables -t nat -A PREROUTING -p TCP --dport 80 -j REDIRECT --to-port 3128
*****

Is this O.K.
Thanks

George Vieira <[email protected]> wrote:
You have not used MASQUERADE in your POSTROUTING rules or haven't showed it..

iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.42 -d 207.106.22.35 --dport 80 -j MASQUERADE iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.23 -d 207.106.22.35 --dport 80 -j MASQUERADE

without the rules above, the 192.168.0.XX packets leave the network out into the internet and eventually get dropped by some ISP...

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of ads nat
Sent: Wednesday, August 27, 2003 4:53 PM
To: [email protected]
Subject: SMTP HTTP port allow

I am implimenting iptables for first time.
I want to allow all my LAN users to send emails to SMTP (port no. 25) all destination with following code. :

***
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT
***

I also want to allow LAN users having ip 192.168.0.42 192.168.0.23 to upload contents to webserver on ip 207.106.22.35 (outside of LAN) with following code.

***
iptables -A FORWARD -p tcp -s 192.168.0.42 192.168.0.23 -d 207.106.22.35 --dport 80 -j ACCEPT
***

I would loke know whether It works or not.
Tell me whether my code is O.K. also where can i check logs. Thanks

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

#4 lore raw
In reply to ads nat
Quoted 6 lines · ads nat

I am implimenting iptables for first time.
I want to allow all my LAN users to send emails to SMTP (port no. 25) all destination with following code. :

***
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT
***

That looks fine. If you want to test a specific rule, replace ACCEPT with LOG and test it. Use --log-prefix to identify these entries. In your case:

iptables -A FORWARD -p tcp --dport 25 -j LOG --log-prefix "dport_25_packet: "

Quoted 9 lines

I also want to allow LAN users having ip 192.168.0.42 192.168.0.23 to upload contents to webserver on ip 207.106.22.35 (outside of LAN) with following code.

***
iptables -A FORWARD -p tcp -s 192.168.0.42 192.168.0.23 -d 207.106.22.35 --dport 80 -j ACCEPT
***

I would loke know whether It works or not.
Tell me whether my code is O.K. also where can i check logs.

iptables uses the kernel system log. In my Redhat system that can be found as /var/log/messages.

Quoted 4 lines

Thanks
------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder <http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com> - Free, easy-to-use web site design software

#3 lore raw
In reply to George Vieira
Quoted 11 lines · George Vieira

You have not used MASQUERADE in your POSTROUTING rules or haven't showed it..

iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.42 -d 207.106.22.35 --dport 80 -j MASQUERADE
iptables -A POSTROUTING -t nat -p tcp -s 192.168.0.23 -d 207.106.22.35 --dport 80 -j MASQUERADE

without the rules above, the 192.168.0.XX packets leave the network out into the internet and eventually get dropped by some ISP...

Again and again, a correction to the statement above. The ISP's do not drop these packets because the src is private IP. It's the return packets which would be dropped because the "defaultless" core routers don't know where to forward them.

Ramin