Jump to content

Change Outgoing IP of Qmail via IPtables - Done on Egovworld

From TetraWiki


Objective[edit]

Some time you have to change the Outgoing IP address of Qmail or postfix etc as your IP got Blacklisted and fortunately you have multiple IP ( as Virtual IPs ). It is not Required to patch the Qmail or Change configuration at postfix . You can do it via IP tables

ISSUE at Egovworld Server[edit]

The IP 67.223.235.55 of Egov world Server was blacklisted .

There was no way to patch Qmail as it was on KLOXO platform .

Reference URL[edit]

http://blogs.reliablepenguin.com/2009/03/05/change-outgoing-ip-address-for-smtp

Resolution[edit]

We have multiple IPs on the Server which are virtual IP ex 67.223.235.167 ( for which Reverse PTR is also mapped )

So we implemented an Iptables rule to Change outgoing IP address for SMTP as Shown Below

/sbin/iptables -t nat -A POSTROUTING -p tcp --dport 25 -j SNAT --to-source 67.223.235.167

This Sorted out outgoing IP Issue

Testing[edit]

You can check the Change of IP in the Sent mail Header as shown below

Return-path: <tetra_test@egovindia.org>
Delivered-to: biswajit@tetrain.com
Received: (qmail 24140 invoked by uid 510); 7 Jan 2014 16:07:08 -0000
Received: from 67.223.235.167 by mail.tetrain.com (envelope-from <tetra_test@egovindia.org>, uid 501) with qmail-scanner-1.25-st-qms   (clamdscan: 0.91.1-exp/3884. spamassassin: 3.0.2. perlscan: 1.25-st-qms.    Clear:RC:0(67.223.235.167):SA:0(2.3/5.0):.  Processed in 3.544045 secs); 07 Jan 2014 16:07:08 -0000