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.