Linux能ping通IP,ping不通網域名稱

來源:互聯網
上載者:User

標籤: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 通網域名稱了。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.