Ping the native hostname problem

Source: Internet
Author: User
Tags bind

Premise: No host name record is added to the/etc/hosts file, and the/etc/resolv.conf file is not configured correctly (or not configured).
Phenomenon: On the CentOS7, only modified the native hostname, ping the result is a bit strange.
Explain:
Originally in the/etc/nsswitch.conf file, the hosts have one more item:

#hosts:     DB Files nisplus NIS DNS
hosts:      files DNS myhostname

Is that the Myhostname item,/etc/hosts and DNS are not resolved to the IP, Myhostname is in effect, it can be hostname, resolved to their own range of IP address, so you can ping through.

You can view the IP for hostname with the following command:

# getent ahosts ' hostname '
fe80::f816:3eff:fe26:6d42 STREAM centos7-bind-1
fe80::f816:3eff:fe26:6d42 DGRAM  
fe80::f816:3eff:fe26:6d42 RAW    
192.168.122.84  STREAM 
192.168.122.84  dgram  
192.168.122.84  RAW    
# ping ' hostname '
ping centos7-bind-1 (192.168.122.84) bytes of data.
Bytes from centos7-bind-1 (192.168.122.84): icmp_seq=1 ttl=64 time=0.120 ms @
bytes from centos7-bind-1 (192.168. 122.84): icmp_seq=2 ttl=64 time=0.043 ms

Nss-myhostname, libnss_myhostname.so.2 English Description:
Nss-myhostname, Libnss_myhostname.so.2-provide hostname resolution for the locally configured system hostname.

Nss-myhostname is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) primarily Prov IDing hostname resolution for the locally configured system hostname as returned by GetHostName (2). The precise hostnames resolved by this module is:

The local, configured hostname is resolved to all locally configured IP addresses ordered by their scope, or-if none was Configured-the IPv4 address 127.0.0.2 (which is on the local loopback) and the IPV6 address:: 1 (which is the local hos T).

The hostname "localhost" is resolved to the IP addresses 127.0.0.1 and:: 1.

The hostname "Gateway" is resolved to all of the default routing gateway addresses, ordered by their metric. This assigns a stable hostname to the current gateway, useful for referencing it independently of the current network conf Iguration state.

Myhostname Detailed URL:
Http://www.freedesktop.org/software/systemd/man/nss-myhostname.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.