Linux can ping IP, ping nowhere domain

  
        

I encountered a problem today, I can ping the IP address, ping nowhere domain name, I always thought it was a DNS resolution server problem, looking for a long time, the problem is not here.

[root@www 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[root @www postfix]# 

Looked at the routing table, the problem is not on the routing gateway.

[root@www 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[root@www Postfix]# [root@www postfix]# [root@www postfix]# [root@www postfix]# [root@www postfix]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface115.28.80.0 * 255.25 5.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

Then look at it:

[root@www postfix]# grep hosts /etc/nsswitch.conf#hosts: db files nisplus nis dns#hosts: files dnshosts: dns files I modified to dns first, In files, tested, it still doesn't work. 

Finally found the reason for the firewall, I turned on the firewall, causing the ping domain name to be unreachable.

Domain name resolution uses port 53, you need to configure the following settings into the firewall.

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
Copyright © Windows knowledge All Rights Reserved