我正在尝试设置一些防火墙规则,允许在一个服务器和另一个服务器之间使用SSH、传入ping、munin和MySQL (所有这些服务都可以使用我的规则),但是当我应用这些规则时,我不能再ping或解析任何DNS (因此我可以平74.125.225.65,而不能解析google.com)。
下面是我使用的规则:
# Accept traffic on localhost:
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow SSH from anywhere:
iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
# Accept ICMP Ping requests (incoming and outgoing):
iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
# Allow munin from subdomain.example.com:
iptables -I INPUT -p tcp -s 123.23.45.1 --dport 4949 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp -d 123.23.45.1 --dport 4949 -m state --state ESTABLISHED -j ACCEPT
# Allow MySQL from subdomain.example.com:
iptables -I INPUT 2 -p tcp -s 123.23.45.1 --dport 3306 -j ACCEPT
iptables -A OUTPUT -p tcp -d 123.23.45.1 --dport 3306 -j ACCEPT
# Drop all other traffic:
iptables -A INPUT -j DROPresolv.conf,/etc/hosts等都是正确的,如果我只做一个$ iptables -F,然后再点击谷歌,它就可以正常工作了。只有在应用了防火墙规则之后,我才能得到ping: unknown host google.com。
发布于 2012-12-14 19:12:16
您没有允许DNS通信的规则,那么它如何工作呢?
https://serverfault.com/questions/458167
复制相似问题