The short answer is that you cannot set up tcpserver to run on more than one address, unless it’s going to run on all addresses. To run qmail-smtpd on two addresses, you need to run two copies of qmail-smtpd.
I needed to run one copy on the public IP address, and one copy for localhost.
(The reason for this change was to test-flight another email server that wanted to bind to port 25 on a specific address. The normal qmail configuration binds qmail-smtpd to all addresses.)
Doing this is pretty easy. On Ubuntu 18.04, the service control directories are in /etc/qmail.
sudo -s cd /etc/qmail svc -d qmail-smtpd cp -ar qmail-smtpd-localhost # edit qmail-smtpd-localhost/run and change the 0 argument to tcpserver 127.0.0.1 rm qmail-stmpd-localhost/supervise cd /etc/service ln -s /etc/qmail/qmail-smtpd-localhost . svc -u qmail-smtpd
The code in run is like:
id -u qmaildNOFILESGID=
id -g qmaildMAXSMTPD=
head -1 /var/lib/qmail/control/meMAILSERVERIP=127.0.0.1 if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in echo /var/qmail/supervise/qmail-smtpd-localhost/run exit 1 fi if [ ! -f /var/lib/qmail/control/rcpthosts ]; then echo "No /var/lib/qmail/control/rcpthosts!" echo "Refusing to start SMTP listener because it'll create an open relay" exit 1 fi exec softlimit -m 90000000 \ tcpserver -v -R -l "$LOCAL" -x /etc/qmail/tcp.smtp.cdb -c "$MAXSMTPD" \ -u "$QMAILDUID" -g "$NOFILESGID" $MAILSERVERIP smtp qmail-smtpd 2>&1