我在Cent OS上启用了DNS解析和iptables。DNS工作正常。iptables配置如下:

[root@LVS02 ipvsadm-1.24]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination        

ACCEPT     icmp --  anywhere             anywhere            

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable            

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination        


Chain OUTPUT (policy ACCEPT)


Chain RH-Firewall-1-INPUT (0 references)

target     prot opt source               destination


当使用wget下载keepalived时,提示无法解析域名

[root@LVS01 ~]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24-5.src.rpm

--2013-08-03 00:02:46--  http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24-5.src.rpm

Resolving www.linuxvirtualserver.org... failed: Temporary failure in name resolution.

wget: unable to resolve host address `www.linuxvirtualserver.org'

为何?

仔细看了一下iptables,还是规则没有写好,没有允许DNS查询返回报文(和cisco的acl对比,我感觉应该不需要添加其他规则,也许这就是不同吧)。那就添加一个吧。

#iptables -I INPUT 4 -p tcp --sport 53 -j ACCEPT

#iptables -I INPUT 5 -p udp --sport 53 -j ACCEPT

这两个语句的意思是,允许源端口为53的数据包,不管是udp还是tcp都可以进入该主机。


最后别忘了保存iptable配置。否则重启iptables服务或重新启动主机,配置就丢失了。

#service iptables save