Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 01-31-2008, 12:05 AM   #1
Registered: May 2006
Posts: 89

Rep: Reputation: 15
want to get SMTP and POP3 working through iptables.

I have a newly configured RHEL4 machine to work as a firewall and Proxy. Squid proxy is working just fine with all applications.

I have a ADSL router with Static WAN ip and LAN ip of the router is
LAN ip is connected to external interface of Gateway/Firewall machine ( on which i have configured squid and iptables ) whose IP is
Internal interface of the gateway machine is
I have a sendmail server with ip who sends mails to external SMTP server and uses fetchmail with POP3 protocol to fetchmails from that same external server.
I have Winproxy currently working with no problems and I want to shift to iptables .

I tried with following commands which did not work. I am a beginner of Iptables.

/sbin/iptables -A INPUT -p tcp --dport 25 -m state --state NEW -j ACCEPT

#Port Forward SMTP to the mailserver

/sbin/iptables -t nat -A PREROUTING -p tcp -d --dport 25 -j DNAT --to-destination
/sbin/iptables -A FORWARD -p tcp -d --dport 25 -j ACCEPT

#SNAT for port 25 and 110

/sbin/iptables -t nat -A POSTROUTING -p tcp -s --dport 25 -o eth1 -j SNAT --to-source
/sbin/iptables -t nat -A POSTROUTING -p tcp -s --dport 110 -o eth1 -j SNAT --to-source

Please help me to get this problem solved.
Old 01-31-2008, 03:32 AM   #2
Simon Bridge
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
From what you have shown us, I'd want to have a look at the order your rules are applied.
The environment that your rules live in can be important. eg.
Is the gateway managed by port forwarding or as a bridge?
Do you use default drop policies?
Do you accept incoming established or related packets?
Do you filter outgoing packets?

Some examples...

Your rules suggest that you expect new incoming smtp connections "unannounced"... doesn't the mail-server have to request these from the external mail-server?
Old 01-31-2008, 04:54 AM   #3
Registered: May 2006
Posts: 89

Original Poster
Rep: Reputation: 15
SMTP and POP3 through iptables

I am totally unaware of questions you are asking.

I have started learning iptables. I am a totally fresher in iptables.
The rules I have implemented are from a book, which I tried to mould as per my metwork.

Can you provide me iptables rules for this network.

Also it will be a great help it you can tell me how to start learning iptables from scratch.
Old 01-31-2008, 05:12 AM   #4
Registered: Dec 2007
Location: Canada
Distribution: RHEL,Fedora
Posts: 995

Rep: Reputation: 115Reputation: 115

have a look
Old 02-01-2008, 12:46 AM   #5
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 18.3+19.0, MX-18
Posts: 4,297

Rep: Reputation: Disabled
This is the guide:

And it is really, really good.
Old 02-01-2008, 07:56 AM   #6
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
I would have said "This is the guide: ..."
No argument from me, Oskar Andreasson, has been the iptables tutorial guru for years.

Thanks Simon & dyasny for the other links, they look interesting, too.

I hope you learn quickly & can afford down time due to mistakes -- it sounds like you're taking on a major educational experience. Good Luck.
Old 02-01-2008, 08:16 AM   #7
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 18.3+19.0, MX-18
Posts: 4,297

Rep: Reputation: Disabled
Right you are. Comes from hurrying out answers. Everybody please take note: This is the guide... as archtoad6 rightly pointed out.




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
SMTP/POP3 problems with squid/iptables dragonleech Linux - Security 8 09-23-2010 04:57 AM
SMTP AND POP3 through iptables vedang Linux - Server 5 01-30-2008 11:47 PM
Iptables Configuration for pop3 and smtp access ! help Pluster Linux - Networking 3 05-13-2006 12:24 AM
SMTP/POP3 iptables problem dragonleech Linux - Security 4 12-12-2005 11:33 AM
POP3/SMTP-IPTABLES Problems chris Linux - Networking 1 02-28-2003 04:55 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:15 PM.

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