Linux can ping IP but cannot ping host domain name resolution reprinted December 25, 2013 10:24:27 13749.vi/etc/nsswitch.confhosts:files Dnsnetworks:files changed to: hos Ts:files DNS Winsnetworks:files if not the same, in the hosts: the original line after the addition of a wins on the line. --------------------------------------------------------------------------------------------------------------- -----------------------------------------------recently encountered a problem: Ping a domain name domain_name when prompted "Ping:unknown host Domain_ Name ", but the IP address of the ping domain name (obtained using host or nslookup) is not a problem. The standard C library, libc && glibc, implements the ISO C standard and includes a set of functions that all C programs can use. LIBC are often used as shorthand for the standard C library. LIBC is also used as the implementation name for a standard C library. In the early the 1890s, developers of the Linux kernel isolated glibc 1.x (forked glibc) and called it "Linux libc", or libc. Linux libc mainly released 2, 3, 4, 54 versions. In 1997, the FSF released GLIBC 2.0, which has better support for POSIX standards and better code portability. As a result, all major Linux distributions are now using GLIBC. The last so-name of Linux libc is libc.so.5. So later the GLIBC 2.x used the so-name is libc.so.6. Network Information Services (Information Service, NIS) NIS, also known as YP (Yellow Pages), is a client/server system based on RPC (Remote Procedure call Protocol) that allows A group of machines in an NIS domain shares a series ofThe file is placed. In an NIS environment, there are three types of hosts for the primary server, the slave server, and the client. The role of the server is to act as a central database for host configuration information. The authoritative copy of this information is kept on the primary server, and the slave server is a redundant copy of the information. Clients rely on the server to provide this information to them. DNS Resolver A domain name consists of one or more tags (label), separated by dots. The right-most label represents the top-level domain (top-level domain,tld). DNS (domain Name System) is a core service of the Internet, a distributed hierarchical system that maps domain names and IP addresses to each other. DNS implements a hierarchical domain name space by allowing a domain name server to delegate a subset of its domain name resolution services to a child server. DNS consists of the parser (Resolver) and the domain name server two parts. The client for the DNS system is known as the DNS resolver (DNS Resolver). On a Linux system, the parser is not referring to an application, but rather to the parser library. This library contains a series of functions in the standard C library, the main two functions are gethostbyname () and gethostbyaddr (). DNS parsers can be configured to look for information in/etc/hosts, to query DNS servers, or to use configuration information from a network information services system. libc use/etc/host.conf configuration file; glibc use/etc/nsswitch.conf profile. The main options in/etc/host.conf are: (1) Order specifies the lookup order of the domain name resolution, where hosts represents the/etc/hosts configuration file, bind means querying the DNS server, and NIS represents the configuration information for querying the NIS system. (2) Multi [On|off] Specifies whether the host in the/etc/hosts can have more than one IP address. /etc/nsswitch.conf is the configuration file for the name Service switch, where the database name corresponding to the DNS resolver is the hosts:. Its main options are: (1) DNS representation using DNS resolution address (2) files means using the/etc/hosts and/etc/network Profiles (3) NIS or nisplus. The DNS server is configured in/etc/resolv.conf. The ping ping command is used to test whether a host on the network can connect. The ping command sends ICMP (INT) to the target hostErnet Control message Protocol) The Echo request message then waits for the target host to respond, while calculating the round trip time (round-trip Time,rtt) of the message from the source host to the destination host. Problem solving First, you can ping the IP address of the domain name, it is obviously impossible for the server to disable the ping service (using firewalls, etc.). Host and Nslookup can return the IP address corresponding to the domain name, then the DNS settings in/etc/resolv.conf are not a problem. In fact, when using the ping command to process a domain name, use the gethostbyname () function to return the corresponding host information (participate in the source code); Host and nslookup are directly using DNS servers in the/etc/resolv.conf. Therefore, you need to see the hosts in/etc/nsswitch.conf: Whether the database has DNS options turned on.
Workaround for Linux to ping IP but not ping host domain name vim/etc/nsswitch.conf hosts:files DNS wins