这是我的问题:
# iptables -P INPUT DROP
# host -t mx gmail.com
;; connection timed out; no servers could be reached
# iptables -P INPUT ACCEPT
# host -t mx gmail.com
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
在将 iptables 设置为丢弃所有输入数据包(除非另有说明)后,我无法解析主机,因此 postfix 无法发送邮件。我认为设置防火墙至关重要 - 我遗漏了什么防火墙设置?
这是我现在的 iptables:
# iptables -L INPUT -n -v
Chain INPUT (policy ACCEPT 120 packets, 17552 bytes)
pkts bytes target prot opt in out source destination
2669K 160M fail2ban-ssh-ddos tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22
2669K 160M fail2ban-ssh tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22
122 19135 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
252 27262 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:143
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587
46 3191 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
264 2459K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
答案1
您缺少一条基于现有流量接受流量的规则(使 iptables 有状态的规则)。这应该是您的第一条规则:
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT