iptables阻止DNS

我在我的防火墙configuration上解除了端口53的阻塞,但是我的防火墙仍在阻止我的dns查找。

我知道DNS查找工作,因为如果我更改我的默认input策略为ACCEPT,则名称parsing正确完成。

这是iptables脚本

Generated by iptables-save v1.3.5 on Fri Dec 3 12:23:49 2010 *filter :INPUT DROP [41:3304] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [558:59294] :RH-Firewall-1-INPUT - [0:0] -A INPUT -i eth0 -p tcp -m tcp --sport 1024:65535 --dport 22 -j ACCEPT -A INPUT -s 172.16.0.134 -p tcp -m tcp --sport 1024:65535 --dport 80 -j ACCEPT -A INPUT -s 172.16.0.134 -p tcp -m tcp --sport 1024:65535 --dport 443 -j ACCEPT -A INPUT -s 172.16.0.134 -p tcp -m tcp --sport 1024:65535 --dport 20 -j ACCEPT -A INPUT -s 172.16.0.134 -p tcp -m tcp --sport 1024:65535 --dport 21 -j ACCEPT -A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT -A INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT -A INPUT -p udp -m udp --dport 53 -j ACCEPT -A OUTPUT -s 172.16.0.4 -j DROP -A OUTPUT -s 172.16.0.136 -j DROP -A OUTPUT -s 172.16.0.135 -j DROP COMMIT # Completed on Fri Dec 3 12:23:49 2010 <code> 

iptables -L的收益

 [root@saas-dev-dcpc ~]# iptables -L Chain INPUT (policy DROP) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpt:ssh ACCEPT tcp -- 172.16.0.134 anywhere tcp spts:1024:65535 dpt:http ACCEPT tcp -- 172.16.0.134 anywhere tcp spts:1024:65535 dpt:https ACCEPT tcp -- 172.16.0.134 anywhere tcp spts:1024:65535 dpt:ftp-data ACCEPT tcp -- 172.16.0.134 anywhere tcp spts:1024:65535 dpt:ftp ACCEPT icmp -- anywhere anywhere icmp any ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns ACCEPT tcp -- anywhere anywhere tcp dpt:domain ACCEPT udp -- anywhere anywhere udp dpt:domain Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination DROP all -- 172.16.0.4 anywher DROP all -- 172.16.0.136 anywhere DROP all -- 172.16.0.135 anywhere Chain RH-Firewall-1-INPUT (0 references) target prot opt source destination 

认为这将被解决,如果你添加一个-m state --state RELATED,ESTABLISHED -j ACCEPT规则到所有链。 它看起来像你可能只允许在一个方向的DNSstream量。

或者,也可以使用--sport 53尝试规则。

所以你的DNS数据包被INPUT链的DROP策略阻塞了,尽pipe你明确的拥有了iptables规则,这个规则应该接受UDP和TCP数据包到端口53.这很奇怪。 要获得更多有关错误的线索,请在您的iptables规则集的末尾添加一条LOG规则,如下所示:

 iptables -A INPUT -j LOG 

做一些DNS查询,并查看系统日志文件(可能是/var/log/syslog和/或/var/log/messages )中显示的内容(如果有的话)。 如果传入的DNS查询包丢失,则按上述规则进行logging。

如果没有在日志中显示,那么其他事情就会出错,阻止您的DNS服务器响应。 不知道你的系统的任何事情,我不会冒许多猜测,但我注意到,你还没有排除从INPUT过滤环回适配器。

尝试将以下内容添加到规则集的顶部:

 -A INPUT -i lo -j ACCEPT 

即使这不能解决你的问题,但是也可以包含这个规则,因为有些程序依赖于正常工作的回送适配器来正常工作。