现象:
不能发邮件,报错无法连接邮件服务器
telnet smtp.163.com 465端口,不通
在同网段的其他服务器测试,可以。定位为此服务器的问题。
检查iptables,策略为允许icmp和特定ip,其他拒绝,最后一条为:
-A INPUT -j REJECT —reject-with icmp-host-prohibited
打开tcpdump抓包
tcpdump host smtp.163.com -i em3 # em3为外网网口
看到icmp-host-prohibited字样
增加一条iptables规则
sudo iptables -I INPUT 7 -s 220.181.12.18/32 -j ACCEPT #为smtp.163.com的ip
telnet 的问题解决,握手成功。
midc@pha:~$ telnet 220.181.12.18 465 Trying 220.181.12.18… Connected to 220.181.12.18.
Escape character is ‘^]’.
Connection closed by foreign host.
TCPdump:
midc@pha:~$ sudo tcpdump host 220.181.12.18 -i em3
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on em3, link-type EN10MB (Ethernet), capture size 262144 bytes
11:16:24.796521 IP ubuntu-R920-2.midc.54598 > m12-18.163.com.urd: Flags [S], seq 3936977535, win 29200, options [mss 1460,sackOK,TS val 4002279548 ecr 0,nop,wscale 7], length 0
11:16:24.833942 IP m12-18.163.com.urd > ubuntu-R920-2.midc.54598: Flags [S.], seq 2701804405, ack 3936977536, win 14480, options [mss 1460,sackOK,TS val 3382967984 ecr 4002279548,nop,wscale 7], length 0
11:16:24.834049 IP ubuntu-R920-2.midc.54598 > m12-18.163.com.urd: Flags [.], ack 1, win 229, options [nop,nop,TS val 4002279586 ecr 3382967984], length 0
11:16:39.740786 IP ubuntu-R920-2.midc.54620 > m12-18.163.com.urd: Flags [S], seq 1417531113, win 29200, options [mss 1460,sackOK,TS val 4002294492 ecr 0,nop,wscale 7], length 0
11:16:39.777043 IP m12-18.163.com.urd > ubuntu-R920-2.midc.54620: Flags [S.], seq 83674110, ack 1417531114, win 14480, options [mss 1460,sackOK,TS val 3382982928 ecr 4002294492,nop,wscale 7], length 0