How to force Sendmail to send outbound email from a list of multiple source IP addresses bound to one Interface so the received from header is different with each outbound email.

Posted on 2009-04-24
Last Modified: 2013-12-17
I want the received from source IP address to be different each time, not just after failover.  Assume I setup a list of 127 IP addresses bound to 1 NIC and that each time I send an email through Sendmail I want it to select the IP to use for delivery either randomly or run through a list of IP addresses serially.
Question by:dmaislin
    LVL 1

    Expert Comment

    If you have access to your DNS server (or you can set one up on the same system), I would set up a DNS entry for outgoing.<yourdomain> with 127 A records in it, and a very short TTL (time to live). DNS tends to go through the A records sequentially. Thenyou set your outgoing sever to that outgoing.<yourdomain> address.
    LVL 26

    Accepted Solution

    Sendmail doesn't work that way. You can have it listen on all 127 addresses, but it is always going to send out mail on the primary address on the interface (not the 126 aliases).

    You can however do this with iptables on the mailserver:

    iptables t nat A POSTROUTING s j SNAT -to

    This basically says if the source address (-s) is, whatever the primary address sendmail uses for sending out, rewrite it to an address in the range of to (your 127 aliases). I've only ever SNAT'd to 1 address, not a range, but I saw a few webpages that say you can do it. Give it a shot.

    LVL 26

    Assisted Solution

    arg, pasted from a website with an obviously different character encoding....

    iptables -t nat -A POSTROUTING -s -j SNAT --to

    Author Comment

    Let me discuss these options with others and see which option is the best option.  The Sendmail is installed on a custom kernel.  Not sure which option will be supported until I login tomorrow.

    Author Closing Comment

    As we all know, the best option would be not to mess with IP, employ DKIM, SPF, Queue Groups, Rate Throttling, etc., but I did think that this is one of the more creative option I have seen to date.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Want to promote your upcoming event?

    Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

    I have seen a lot of questions on EE where there have been problems sending out emails to one or more external email domains and most issues can be resolved fairly simply by checking to see that your Mail Server configuration is setup optimally and …
    Getting postfix to support IPv6 is a relatively simple matter (when you know how - or - have read this Article). First of all you must ensure that your server has IPv6 connectivity to the Internet. By default postfix will listen only on IPv4, …
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now