How does the/etc/hosts file take effect after modification ?, Etchosts

Source: Internet
Author: User

How does the/etc/hosts file take effect after modification ?, Etchosts

After modifying/etc/hosts, it is normal that it takes effect immediately after being saved, but sometimes it is not. You can use uname-a to check the hostname and check whether the modification takes effect. If no

The following policies are available:

1) restart the machine

2) restart the service

Ubuntu: $ sudo/etc/init. d/networking restart

Gentoo:/etc/init. d/net. eth0 restart

3) use the hostname command

Host Name Defined by hostname

Relationship between hostname and/etc/hosts

Many people mentioned the idea of modifying the hostname first to modify the/etc/hosts file. The configuration file of hostname is/etc/hosts. Actually not.

The hosts file acts like DNS and provides the corresponding IP address to the hostname. There were few computers on the Internet in the early days, and the hosts file on a single machine was enough to store all the computers on the Internet. However, with the development of the Internet, this is far from enough. As a result, a distributed DNS system emerged. The DNS server provides a similar IP address to the corresponding domain name. Man hosts is supported.

The Linux system will query the/etc/hosts file before sending a domain name resolution request to the DNS server. If there is a corresponding record in it, the record in hosts will be used. The/etc/hosts file usually contains this record.

127.0.0.1localhost.localdomainlocalhost

The hosts file is in the format of one record per line, namely, the IP address hostnamealiases. The three are separated by blank characters. aliases is optional.

We recommend that you do not modify the configuration from 127.0.0.1 to localhost, because many applications use this configuration, such as sendmail. After modification, these programs may not run properly.

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.