LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-24-2006, 10:16 PM   #1
pau_kacang
Member
 
Registered: May 2005
Location: Malaysia
Posts: 33

Rep: Reputation: 15
Mail Port Foward On Iptables


hello,
i,m newbie in slack. i got problem with my iptables. my linux box running as router using squid.

iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE

when i put this line to my iptables i can browsing direct to internet without put the proxy on my browser n i also can access my isp email server. if i remove that line, i must put proxy setting on my browser & it's running but i can't access email from my isp. so my conclusion when i put that line it will forward all port to internet. i just want allow port 3128,8080,25 & 110 to forwards.

can any body help me how to solved that problem.
 
Old 01-25-2006, 03:04 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
That line does not forward any ports or traffic at all. It makes the packets look like they all come from your external IP address. Your private LAN IP addresses can't be routed onto the internet so they need to look like (ie masquerade) they came from your public IP address.

Just about everyone here with a LAN/Linux/bridged modem/Internet setup with private IP addresses on their LAN will have a masquerade line (or some type of address translation) in their iptables setup.

Last edited by gilead; 01-25-2006 at 03:06 PM.
 
Old 02-17-2006, 09:09 PM   #3
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Rep: Reputation: 30
Cool

Quote:
Originally Posted by pau_kacang
hello,
i,m newbie in slack. i got problem with my iptables. my linux box running as router using squid.

iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
this command will allow everyone to connect to anywhere and to any port. You may not want to do this.

Quote:
Originally Posted by pau_kacang
when i put this line to my iptables i can browsing direct to internet without put the proxy on my browser n i also can access my isp email server. if i remove that line, i must put proxy setting on my browser & it's running but i can't access email from my isp. so my conclusion when i put that line it will forward all port to internet. i just want allow port 3128,8080,25 & 110 to forwards.

can any body help me how to solved that problem.
to redirect to squid port (say 3128),

iptables -t nat -I PREROUTING -s ur_local_lan -p tcp -j REDIRECT --to-port 3128

Last edited by zamri; 02-17-2006 at 09:13 PM.
 
Old 02-17-2006, 09:29 PM   #4
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
Try something like:
Code:
iptables -t nat -A PREROUTING -i $EXT_DEV -p tcp --dport 25 -j DNAT --to <Mail server IP>:25
iptables -A FORWARD -i $EXT_DEV -p tcp --dport 25 -j ACCEPT
$EXT_DEV is your external facing network device.
 
  


Reply

Tags
iptables, port, prerouting, redirect


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Sendmail forward all incoming mail to localhost port 26 (Domino mail) speedgelb Linux - Software 3 09-27-2013 10:18 AM
Iptables - incomming port to external port - possible? ziggie216 Linux - Software 1 07-13-2006 02:08 PM
straight-foward answer: printing through parallel port mrchaos Linux - Hardware 7 06-27-2005 04:38 PM
foward domain names to diffrent box techhost Linux - Networking 5 03-30-2005 07:58 PM
Port 80 forwarding to port 22 with iptables zahoo Linux - Networking 3 02-22-2005 07:22 AM


All times are GMT -5. The time now is 05:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration