Configuring Sendmail to Listen on Multiple Specific IPs
As a novice sendmail user, finding information on this fix wasn’t easy. For a long time I was afraid to touch the sendmail.mc. If you aren’t familiar with it, and you plan to administer sendmail, I suggest taking a few minutes to go through the m4 README. It’s not nearly as confusing as I used to think it was.
Once you’ve got sendmail up with multiple IP addresses you may be interesting in the `CLIENT_OPTIONS’ setting. With it you can change the outbound IP address sendmail uses for sending email.
The `confDONT_PROBE_INTERFACE’ option below will keep sendmail from binding to every IP on the box. Even after it is set it is necessary to use the `no_default_msa’ feature to keep the msa from automatically binding to your available IPs. By default sendmail has a 10 `DAEMON_OPTIONS’ restriction. You’ll have to recompile if you need more. As you see below, I’m using 3 per IP address.
## file: /etc/mail/sendmail.mc ##
…
define(`confDONT_PROBE_INTERFACE’, `True’)dnl
FEATURE(`no_default_msa’)dnl
…
DAEMON_OPTIONS(`Family=inet, Addr=127.0.0.1, Port=25, Name=MTA, M=E’)dnl
DAEMON_OPTIONS(`Family=inet, Addr=127.0.0.1, Port=465, Name=MTA-SSL, M=s’)dnl
DAEMON_OPTIONS(`Port=587, Addr=127.0.0.1, Name=MSA, M=E’)dnl
dnl
DAEMON_OPTIONS(`Family=inet, Addr=192.168.0.2, Port=25, Name=MTA, M=E’)dnl
DAEMON_OPTIONS(`Family=inet, Addr=192.168.0.2, Port=465, Name=MTA-SSL, M=s’)dnl
DAEMON_OPTIONS(`Port=587, Addr=192.168.0.2, Name=MSA, M=E’)dnl
…
Now all you need to do is rebuild your sendmail.cf and restart sendmail:
internet ~ # cd /etc/mail
internet /etc/mail # vi sendmail.mc
internet /etc/mail # m4 sendmail.mc > sendmail.cf
internet /etc/mail # /etc/init.d/sendmail restart
* Stopping sendmail … [ ok ]
* Starting sendmail … [ ok ]
internet /etc/mail #