IPtables tricks

iptables -t nat -I PREROUTING -p tcp –destination-port -j REDIRECT –to-ports 25

- redirecting incoming packets to other ports

iptables -t nat -I POSTROUTING -o -http://lists.netfilter.org/pipermail/netfilter/2004-March/051478.htmlj MASQUERADE

- all packets that would go through internet connected interface will be maqueraded

I recently found out that this redirect doesn’t work for traffix generated to the local interface. Following the advice from [this list](http://lists.netfilter.org/pipermail/netfilter/2004-March/051478.html) I made it to work (I don’t know if you need some special kernel options as they suggested it just worked for me on 2.6.x).

iptables -t nat -I OUTPUT -p tcp –destination-port -o lo -d localhost -j REDIRECT –to-ports 25

Leave a Reply