How to redirect/forward port traffic from a certain port to another on Linux

Friday, 10th September 2010

In the University where I study right now Arnhem Business School (ABS) the outbound traffic to port numbers 25, 110 and 995 are filtered.
This is quite unhandy counting the fact that I’m completely dependable to read both my school and job mails via the nice SMTP and POP3 protocols with Thunderbird (Icedove) as called in Debian.

Therefore I looked for a good way to create a port redirect from the filtered 25, 110 and 995 to allowed outbound ports.

A quick nmap port scan revealed me that the three outbound ports 2010 and 2050 and 2060 are allowed to pass network traffic.

Therefore after some research on forums onine and some consulting in irc.freenode.net I’ve found a way to add a redirect rule with iptables.
Below are the three rules I used to redirect my ports 25,110 and 995 to port numbers 2010 2050 and 2060 on localhost where a qmail mail server is serving my mail

debian:~# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 2050 -j REDIRECT --to-ports 25
debian:~#
debian:~# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 2010 -j REDIRECT --to-ports 110
debian:~#
debian:~# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 2060 -j REDIRECT --to-ports 995
debian:~#

That’s all now I just had to change the configuration in my Thunderbird client and set the ports 2050, 2010 and 2060 in place of the normal 25, 110, 995

Share this on:

Download PDFDownload PDF

Tags:

Leave a Reply

CommentLuv badge