Iptables – Routing outbound SMTP with IPTables

iptablessmtp

I am trying to transparently filter outbound SPAM from one of my hosting boxes. I have set up an external mail server that filters SPAM and now I am looking for a way to route all outbound SMTP traffic from the hosting server to the Mail Scanner with IPTables.

Eg. — Outbound SMTP (1.1.1.1 port 25) –> MailScanner (6.6.6.6 port 2500)

So far my closest attempt has lead me to LAND attacks showing on our CISCO firewalls.

iptables -t nat -A POSTROUTING -o eth0 -p tcp -j SNAT --dport 2500 --to-source 6.6.6.6

Best Answer

I think you may consider where the outbound trafic are going to, it go from 1.1.1.1 port 25 to ? you have to mach this trafic -and only this- and send it to 6.6.6.6

May be --sport 25 are enought.