Sendmail 持续监听本地 IP

Sendmail 持续监听本地 IP

我正在运行 RHEL 6 并且已经完成以下修改:

[root@ark mail]# grep 0.0.0.0 sendmail.mc
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

[root@ark mail]# make sendmail.cf

确保它确实适用:

[root@ark mail]# grep 0.0.0.0 sendmail.cf
O DaemonPortOptions=Port=smtp,Addr=0.0.0.0, Name=MTA
#O ClientPortOptions=Family=inet, Address=0.0.0.0
#O ConnectOnlyTo=0.0.0.0

[root@ark mail]# makemap -v hash access.db < access
key=`connect:localhost.localdomain', val=`RELAY'
key=`connect:localhost', val=`RELAY'
key=`connect:127.0.0.1', val=`RELAY'
key=`connect:[my.remote.ip]', val=`RELAY'

但是它仍然在监听 127.0.0.1:

[root@ark mail]# netstat -lptun | grep 25
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1174/master

我已经重新启动 sendmail 几次了。

答案1

[root@server mail]# netstat -vatn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      

查看了几个文件后我发现了修复方法:

首先需要编辑/etc/mail/sendmail.mc,找到以下部分:

dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

您需要使用 DAEMON_OPTIONS 注释掉类似的内容,并在行首使用“dnl”:

dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

然后您将需要重建文件:

m4 /etc/mail/sendmail.mc > /etc/sendmail.cf

完成此操作后,sendmail 将监听系统上的所有 IP 地址:

[root@server mail]# netstat -vatn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      

并且您可以接收其他人的邮件,并发送来自客户的邮件。

答案2

看看/etc/sysconfig/mail。你不会错过远程设置。

相关内容