Modify/etc/hosts in Linux and etchosts in linux

Source: Internet
Author: User

Modify/etc/hosts in Linux and etchosts in linux
Directory structure

  • Directory structure
  • Hosts file
  • Hosts format Configuration
    • Hosts file format
  • Hosts file Function

Hosts file

Hosts -- the static table lookup for host name (host name query static table ).
The hosts file is a file on Linux that is responsible for fast resolution of IP addresses and domain names. It is saved in the/etc/directory in ascii format. The hosts file contains the ing between the IP address and the host name, as well as the host alias. Without a domain name resolution server, all network programs on the system query the file to resolve the IP address corresponding to a host name. Otherwise, the dns service program is required. You can map common domain names and IP addresses to the hosts file for quick and convenient access.
Priority: dns Cache> hosts> dns Service

Hosts format Configuration

You can configure the Host ip address and the corresponding host name in the hosts file. On a LAN or the World Wide Web, each host has an ip address that separates each host and can communicate with each other based on its ip address. However, IP addresses do not conform to the memory of the human brain, so domain names appear. For example, www.baidu.com. In a LAN, each machine has a host name, which is used to distinguish hosts for mutual access.

Hosts file format
IP address host name/domain name (host alias)

The difference between host name and domain name is that:

  • The host name is usually used in the LAN. Through the hosts file, the host name is resolved to the corresponding ip address.
  • Domain names are generally used on the internet, but the priority is lower than the content in the hosts file. Therefore, if you do not want to use domain name resolution on the internet, you can change your hosts file and add your own domain name resolution.
Hosts file Function

One of the main functions is to simulate the offline environment. To access each other through the domain names on the internet in the same LAN, you only need to modify the content of your/etc/hosts file.
For example, modify the ip address of www.baidu.com to 127.0.0.1:

After modifying/etc/hosts, ping Baidu as shown in:

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.