Allowing new port in Linux iptables

With the ever growing popularity for Broad Band providers these days blocking SMTP connections on port 25 I have a quick and dirty way to allow your clients to still use your SMTP servers to send their mail without having to resort to using their broad band providers SMPT servers.

I know recently I have had many support calls and emails from clients telling me that they are able to receive mail with no problem but when they try to send mail their connection times out and they are left with an error message to the effect of “Connection can not be established with SMPT server”.

This method of getting around this is not a end all to be all either. You will still have to tell your clients to connect to port 26 and not the default SMTP port which is 25.

I have tested this on RH Linux. You will need to be running some sort of firewall so you can do some port managing.

This is an IP Tables work-around for your mail server that opens up port 26 and routes all mail to port 25 so that users could set their mail client to port 26 and still use your servers. This allows the clients that don’t want to use their ISP mail settings to still connect.

$IPTABLES -t nat -A PREROUTING -t nat -p tcp -d SERVER_IP_HERE –dport 26 -j DNAT –to SERVER_IP_HERE:25

Just copy the above text, paste it onto the command line, replace the two SERVER_IP_HERE’s with the IP address of the mail server and press enter. Then enter “service iptables restart” into the command line and press enter and then after its done rebooting port 26 will be open and will route all connections to port 25 and the server will treat them as if the connection was to port 25.

I hope this helps some of you. I hate how the board band companies are blocking port 25 now. It is making things hard for us hosts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: