zabbix action无法连接sendmail问题

sendmail介绍:
[url]http://qingwang.blog.51cto.com/505009/909329[/url]
[url]http://blog.csdn.net/imfinger/article/details/6407469[/url]
[url]http://blog.chinaunix.net/uid-1900122-id-2797838.html[/url]
zabbix email 报警设置:[url]http://bbs.linuxtone.org/thread-9401-1-1.html[/url]
上面的连接可以不看,直接看下面的
问题:
[color=red]cannot connect to SMTP server [zabbix.server.com]: cannot connect to [[zabbix.server.com]:25]: [111] Connection refused[/color]
查看sendmail是否开启
# sudo service sendmail status
Redirecting to /bin/systemctl status sendmail.service
● sendmail.service - Sendmail Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/sendmail.service; enabled; vendor preset: disabled)
Active: [color=red]active (running) [/color]since Tue 2016-08-09 18:00:08 CST; 6min ago
Process: 4665 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
Process: 4653 ExecStartPre=/etc/mail/make aliases (code=exited, status=0/SUCCESS)
Process: 4650 ExecStartPre=/etc/mail/make (code=exited, status=0/SUCCESS)
从上可以看出sendmail服务以开启
查看是否有防火墙:
[zabbix@zabbix server]$ sudo cat /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
[color=green]-A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT[/color]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
没有问题
查看端口:
[zabbix@zabbixServer server]$ netstat -ntlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 [color=red]127.0.0.1:25[/color] 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4184/./zabbix_serve
tcp6 0 0 :::3306 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
我们可以看到sendmail只在127.0.0.1上监听,所以无法连上,修改/etc/mail/sendmail.cf
先备份sudo cp etc/mail/sendmail.cf etc/mail/sendmail_bak.cf
sudo vim etc/mail/sendmail.cf
# SMTP daemon options
#注释掉这行,重启服务即可
[color=red]#O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA[/color]

# SMTP client options
#O ClientPortOptions=Family=inet, Address=0.0.0.0

:wq
重启服务
sudo service sendmail restart
再次查看端口:

# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2551/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1226/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3390/cupsd
tcp 0 [color=red]0 0.0.0.0[/color]:25 0.0.0.0:* LISTEN 4691/sendmail: acce
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4049/./zabbix_serve
tcp6 0 0 :::3306 :::* LISTEN 2410/mysqld
tcp6 0 0 :::80 :::* LISTEN 4133/httpd
tcp6 0 0 :::22 :::* LISTEN 1226/sshd
tcp6 0 0 ::1:631 :::* LISTEN 3390/cupsd
telnet 访问25端口
没有telnet,安装sudo yum install telnet
# telnet zabbix.server.com 25
Trying 192.168.126.128...
Connected to zabbix.server.com.
Escape character is '^]'.
220 zabbix.server.com ESMTP Sendmail 8.14.7/8.14.7; Tue, 9 Aug 2016 18:00:37 +0800
^Cquit
quit
Connection closed by foreign host.
-----------------------------------------
OK
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值