LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-01-2008, 04:43 AM   #1
mudasirm
LQ Newbie
 
Registered: Jun 2007
Location: Pakistan
Distribution: RedHat
Posts: 15

Rep: Reputation: 0
PORT FORWARDING for POP and SMTP


I am trying to do Port Forwarding for POP and SMTP. My senario is as follows

INTERNET-- >(eth1 -- real ip)LINUX FIREWALL(eth0 -- class C)-- >Windows XP MAIL SERVER

Mail Server is not on Linux its using Windows XP.

Mail Server is also on Class C IP. I am trying to do Port Forwarding for port 25 and 110, but unable to achieve it. I am using follwing IPTABLES rule to do so

Code:
NETWORK=eth0 
INTERNET=eth1 
REAL_IP=xx.xx.xx.xx 
MAIL_SERVER=xx.xx.xx.xx 

iptables -P INPUT DROP 
iptables -P FORWARD ACCEPT 
iptables -P OUTPUT ACCEPT 

echo 1 > /proc/sys/net/ipv4/ip_forward 

iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT 
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 

iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 25 -j DNAT --to-destination $MAIL_SERVER:25 
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 110 -j DNAT --to-destination $MAIL_SERVER:110 

iptables -A INPUT -p tcp --dport 25 -j ACCEPT 
iptables -A INPUT -p tcp --dport 110 -j ACCEPT 

iptables -t nat -A POSTROUTING -o $INTERNET -p tcp --dport 25 -j SNAT --to-source $REAL_IP 
iptables -t nat -A POSTROUTING -o $INTERNET -p tcp --dport 110 -j SNAT --to-source $REAL_IP
These rules are not working however when i try to do Port Forwarding for other ports like VNC or HTTP in similar manner

Code:
 
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j DNAT --to-destination $MAIL_SERVER:80 
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 5900 -j DNAT --to-destination $MAIL_SERVER:5900
These Rules work perfect.

When i send mail from hotmail or any other mail service i am able to recieve at my internal mail server, but when i send mail from my mail server i am unable to recieve mails any where else except on the same domain.
And when i use a router instead of a linux machine for port forwarding every thing works fine including MAIL TRANSFER from and to the domain.


I think there might be something that i am missing or doing wrong. Please help me out in this.

Looking forward for a positive reply.
 
Old 12-01-2008, 07:43 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
This is really not a firewall as you are allowing all inbound connections to the firewall using this rule.
Code:
iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Nothing is also stopping your outbound smtp connection as your FORWARD chain has policy allow.

You need to check on the windows machine it could be a default gw issue, if not then troubleshoot using tcpdump and telnet.
 
Old 12-02-2008, 12:44 AM   #3
mudasirm
LQ Newbie
 
Registered: Jun 2007
Location: Pakistan
Distribution: RedHat
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

Dear i know this is not a firewall. In real i am using MANGLE table to mark all KNOWN hosts and DROP all unknown hosts, and these DROP rules are at the top of all other rules which makes these rules work fine for me.

The only issue is with SENDING mails from my mail server, not in recieving mails.

I have no Access to Windows Machine, it is a pre-configured IBM Machine which i am not allowed to do anything with.

And can you tell me how can i use TCPDUMP to trace packets and debug this issue

Telnet to the mail server is working fine even from REMOTE location, thats why i am confused why the mail transfer is not working.
 
Old 12-02-2008, 01:34 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
The debugging would only work if you had access to the windows machine, but you can still simulate that using another machine on the lan you need to listen on your internal interface as well as the external interface and see what happens to the packets.
 
Old 12-02-2008, 11:09 PM   #5
mudasirm
LQ Newbie
 
Registered: Jun 2007
Location: Pakistan
Distribution: RedHat
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

Dear i can not simulate this senario, as i said the windows machine has been pre-configured by IBM, so i dont know what are the settings.

And regarding watching the internal and external interfaces, have been doing that for about 3 days, still dont understand where the packets are dropping.

Anyways, now i will try something new, and if it works i will post it here.

And i really appreciate your help.
 
Old 12-03-2008, 12:59 PM   #6
hasanatizaz
Member
 
Registered: Nov 2007
Location: Pakistan
Distribution: Redhat and Debian
Posts: 317
Blog Entries: 1

Rep: Reputation: 35
hello mudasir bhai, congrats for your RHCE and good to see you here.
 
  


Reply



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
Port forwarding smtp kool_kid Linux - Networking 6 12-13-2007 06:33 AM
IPCOP Port Forwarding SMTP problem Casket Linux - Networking 2 11-07-2007 09:15 PM
port forwarding for pop3 and smtp sundar1712 Linux - Networking 2 05-16-2006 07:44 PM
I need a free smtp/pop server, but a win32 port. hunterhunter Linux - Software 6 03-06-2006 09:34 AM
Postfis SMTP forwarding and Incoming SMTP pheasand Linux - Software 0 04-27-2005 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration