我有以下 iptables 规则:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:mysql
ACCEPT tcp -- anywhere anywhere tcp dpt:14443
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp -- anywhere anywhere tcp dpt:xxxxxxx
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Run Code Online (Sandbox Code Playgroud)
当我关闭 iptables 时,我可以使用wget
和所有其他命令。启用这些规则后,我无法连接到任何地址。知道为什么会这样吗?
就此而言,您正在阻止对 DNS 查询的响应以及对 HTTP TCP 连接的响应。
在您的INPUT
链中放置一条规则,以允许已建立的连接和与已建立的连接相关的流量(例如有关路由问题的 ICMP 信息)。
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Run Code Online (Sandbox Code Playgroud)