For Linux and Shell scripting.

How to change source SMTP IP address in sendmail


Follow the steps below, if you want to change the source SMTP ip address in sendmail.

1) change the line below in

#O ClientPortOptions=Family=inet, Address=x.x.x.x
O ClientPortOptions=Family=inet, Address=<ip address you want>

3) restart sendmail

Send a test mail and check its header. The source IP address should have changed 😉


21 thoughts on “How to change source SMTP IP address in sendmail

  1. Good One !!!!

    I think it will be useful to list the steps to change source SMTP IP if exim is the MTA. Here comes the steps

    1. Edit /etc/exim.conf with your favorite editor.
    2. Locate the section of the file that contains the following:
    driver = smtp
    3. Replace this section with the following modified version :
    driver = smtp
    interface =
    4. Restart Exim

  2. Brijesh,
    Thanks for that tip 🙂

  3. Thanks a lot!

    Finally a solution, without going through m4.

  4. Hi,

    Do you know how to change the source IP address for multiple domains ie:

    I have two IP addresses, with two domains on one server, = (Primary) and =

    both of which are sent from from sendmail, and therefore report the wrong rDNS at the receiver end. I need them both to come from their respective ip’s.

    Please note, I use OUTGOING email only.

    Hope you can help

  5. Joe,

    I am not sure if you can set source IP addresses per domains. However, reverse DNS issue is a common thing. The simplest way to resolve this is, set multiple reverse DNS entries for the *outgoing* IP address.


  6. Mohammed

    Thankyou very much for your reply.

    From what I understand, the likes of AOL will only take the first entry they receive for rDNS, making the lookup a bit of a hit and miss affair.


    I may have been a bit premature in my need to have the outgoing server report the actual IP of the sending mail process. From what I have read, the sending email address (or its domain/IP) is not checked, it’s simply the fact that the server that sent the email has an rDNS that matches the HELO/EHLO name in the first communication between the servers. I can set the HELO/EHLO to whatever I want!

    How this really prevents spamming, I’m not sure – are they really suggesting that spammers don’t have servers with IP addresses and a bit of DNS nouse?

    Again thanks very much for your reply, I’ll give the above a go, and let you know – unless of course you already do!!

    Many Thanks,

  7. Joe,

    Thanks for the detailed information. Please try it and let me know how it goes. I think setting rDNS that match the HELO/EHLO name would be fine.

  8. Joe did you succed ? Could you tell us the solution ?

  9. Thanks a lot. This tip have resolved my problem.

  10. I need a good SMTP mail server for sending emails on advert concerning my products.

  11. hello mohammed,

    This is my request to you actually my email got hacked and the person is sending mails using it but the sender ip address is show as with SMTP id u8cs13290rvj; with SMTP id a16mr3157572rvj.290.1267519743248; with SMTP id a16mr3924278rvj.290;

    can u please help me out to find the correct ip add. if possible

    he is playing with my life please help me
    thank you

  12. which one is paswerd here pls?

  13. Hi,

    Please let me know ….is ip rotation is possible in sendmail (every mail sent through different ip address).


  14. punit, I think you could accomplish this using some load-balancing software, like haproxy.

  15. Let me know if anybody has configured this?

  16. Hi Nidhi,

    I have configured this with Exim,but not with sendmail. 🙂

  17. I Like the way you have provided the solution to change the source IP for sendmail.
    It worked for me.

    Thanks a lot.
    Keep going………..

    Mahendra Mewada

  18. Hi, I am using sendmail and have configured to change my source ip address as mentioned above but when I see the original message in gmail my origin ip is still there in the headers. Please suggest something ASAP.

  19. Thank you very much for this post your knowledge in linux and sendmail is very good. It was clear and easy to make the changes I appreciate it.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s