A detailed description of the Hosts file under Linux

Source: Internet
Author: User

A detailed description of the Hosts file under Linux

  1. Host Name:
    Whether on the LAN or the Internet, each host has an IP address to differentiate between this host and its host, that is, the IP address is the host's number.
    Public network: The IP address is not easy to remember, so there is a domain name. Domain names exist only in the public network (the INtERNET), each domain name corresponds to an IP address, but an IP address can have multiple domain names.
    LAN: Each machine has a host name, for the host and the host to facilitate the separation, you can set the host name for each machine, in order to easily remember the way to access each other. For example, we can be named according to the function of each machine in LAN.
    host name-related profiles:/etc/hosts

  2. Hostname configuration file:
    The hostname configuration file is mostly/etc/hosts
    The hosts configuration file is the method used to map host names to IP addresses. But this mapping is only a local machine mapping, which means that each machine is independent, and all computers can not access each other through hostname.
    For example:
    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    127.0.0.1 localhost.localdomain localhost
    192.168.1.195 Debian.localdomain Debian
    In general, the content of the hosts is about the hostname (Hostname) definition, each behavior of a host, each line consists of three parts, each part separated by a space. Where the # starts with a line that is not explained by the system.
    The first part: Network IP address.
    Part two: hostname. Domain name, note that there is a half-width point between the host name and the domain name.
    The second part: hostname (hostname alias), is actually the host name.
    Of course, each line can also be two parts, that is, the host IP address and host name; for example 192.168.1.195 Debian
    Then we have three host, each do a different thing, one to do mail server, one to do FTP server, one to do SMB server, so we can design hostname;
    127.0.0.1 localhost.localdomain localhost
    192.168.1.2 Ftp.localdomain FTP
    192.168.1.3 Mail.localdomain Mail
    192.168.1.4 smb.localdomin SMB
    The contents of this configuration file are written to each machine's/etc/hosts content separately, so that the three LAN machines can be accessed through hostname.

  3. Differences between host name (Hostname) and domain name (domains)
    Hostname is the name of the machine itself, the domain name is used to resolve to the IP. But it is worth saying that in the LAN, the hostname can also be resolved to the IP.

<wiz_tmp_tag id= "Wiz-table-range-border" contenteditable= "false" style= "Display:none;" >

A detailed description of the Hosts file under Linux

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.