標籤:des blog os io 2014 問題 html linux
今天碰到個問題, 能ping通IP地址, ping不通網域名稱, 一直以為是 DNS解析伺服器的問題, 找了半天, 問題不在這裡。
[[email protected] postfix]# cat /etc/resolv.confnameserver 202.96.209.133options attempts:1 timeout:1 rotate#nameserver 10.202.72.117nameserver 10.202.72.118nameserver 114.114.114.114nameserver 8.8.8.8[[email protected] postfix]#
看了一下路由表, 問題也不在路由網關上。
[[email protected] postfix]# netstat -rnKernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface115.28.80.0 0.0.0.0 255.255.252.0 U 0 0 0 eth110.163.176.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1192.168.0.0 10.163.191.247 255.255.0.0 UG 0 0 0 eth0172.16.0.0 10.163.191.247 255.240.0.0 UG 0 0 0 eth010.0.0.0 10.163.191.247 255.0.0.0 UG 0 0 0 eth00.0.0.0 115.28.83.247 0.0.0.0 UG 0 0 0 eth1[[email protected] postfix]# [[email protected] postfix]# [[email protected] postfix]# [[email protected] postfix]# [[email protected] postfix]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface115.28.80.0 * 255.255.252.0 U 0 0 0 eth110.163.176.0 * 255.255.240.0 U 0 0 0 eth0link-local * 255.255.0.0 U 1002 0 0 eth0link-local * 255.255.0.0 U 1003 0 0 eth1192.168.0.0 10.163.191.247 255.255.0.0 UG 0 0 0 eth0172.16.0.0 10.163.191.247 255.240.0.0 UG 0 0 0 eth010.0.0.0 10.163.191.247 255.0.0.0 UG 0 0 0 eth0default 115.28.83.247 0.0.0.0 UG 0 0 0 eth1
然後再看看 :
[[email protected] postfix]# grep hosts /etc/nsswitch.conf#hosts: db files nisplus nis dns#hosts: files dnshosts: dns files
我修改為 先 dns, 在 files, 測試了, 也還是不通。
最後發現是防火牆的原因, 我開啟了防火牆, 造成了 ping 網域名稱不通。
網域名稱解析用到了53連接埠, 需要把下面的設定配置到防火牆裡即可。
iptables -A INPUT -p udp --sport 53 -j ACCEPTiptables -A OUTPUT -p udp --dport 53 -j ACCEPTiptables -A INPUT -p udp --dport 53 -j ACCEPTiptables -A OUTPUT -p udp --sport 53 -j ACCEPT
這樣就可以 ping 通網域名稱了。