Sender Dependent Outgoing IP Address

Introduction to Outgoing IPs

By default, when your mail server sends out email the SMTP connection will come from the system's default IP address, typically that assigned to eth0 . Even if the email is from a domain that has its own private IP, that address will not be used when sending email.

This behavior can be changed on systems running Postfix version 2.7 and Virtualmin 3.94 or later, so that outgoing email from a domain with a private IP address appears to come from that address. This can be useful for separating email from multiple domains as seen by other mail servers, or for setting up per-domain reverse DNS records.

Initial Configuration

This feature requires Postfix 2.7 (seen on most modern Linux distributions), Virtualmin 3.93 and ideally Webmin 1.600. The steps to set it up are as follows :

  1. SSH into the system as root, and edit the /etc/postfix/ file.
  2. Look for a line starting with sender_dependent_default_transport_maps . If it already exists, your system is already ready.
  3. Otherwise, add the line sender_dependent_default_transport_maps = hash:/etc/postfix/dependent
  4. Run the command touch /etc/postfix/dependent
  5. Run the command postmap hash:/etc/postfix/dependent

Enabling In Virtualmin

To enable use of a domain's IP address for outgoing SMTP connections in Virtualmin, simply go to Server Configuration -> Email Settings , and change Send outgoing email for domain from IP to Virtual server's address . Then click the Save button.

You can also enable this feature using the API command modify-mail , with the --outgoing-ip flag.