Linux/etc/hosts file role

Source: Internet
Author: User

1. About/etc/host, hostname and IP profile   hosts:the static table lookup for Host name (hostname query static table)   Linux/etc/hosts is the configuration IP address and It corresponds to the hostname of the file, where you can log the machine or other host IP and its corresponding host name. Different versions of Linux, this configuration file may also be different. For example, the Debian file is/etc/hostname.   2. Configuration file   This file can be configured host IP and corresponding host name, for the server type of Linux system its role is not negligible. On the LAN or the Internet, each host has an IP address that separates each host and can communicate based on IP. But the IP address is not easy to remember, so there is a domain name. In a local area network, each machine has a host name, which is used to differentiate the host and facilitate mutual access. The relevant configuration file for the   Linux hostname is/etc/hosts; This file tells the host which domain names correspond to those IPs, and what IP the hostname corresponds to:   such as the file has such a definition   192.168.102.136 Dbfan & nbsp Aeolus   Assuming 192.168.102.136 is a Web server, entering Http://dbfan or Http://aeolus on a webpage will open the 192.168.102.136/Web page. Dbfan is the domain name, Aeolus is the hostname alias   typically this file first records the native IP and hostname:   127.0.0.1 localhost.localdomain localhost   3. Configuration file Format Description   General/etc/hosts content is generally similar to the following:   127.0.0.1 localhost.localdomain localhost   192.168.102.136 Aeoluspu.com Aeolus     In general, each behavior of the hosts file is a host, each line consists of three parts, and each part is separated by a space. Where the # starts with a line that is not explained by the system.   PART I: Network IP address;   Part II: hostname or domain name;   Third part: hostname alias;   Of course, each line can also be two parts,That is, the host IP address and host name, such as 192.168.102.136 aeoluspu.com.   Here you can explain the difference between host name (hostname) and domain name: hostname is usually used in LAN, through Hosts file, host name is resolved to corresponding IP, domain name is usually used on the internet, However, if the computer does not want to use the domain name resolution on the Internet, you can change the hosts file to join your own domain name resolution.   4. /hosts files can help troubleshoot issues   4.1 Telnet to a Linux host too slow   Sometimes the client wants to telnet to a Linux host, but it waits a long time for the password to enter after each login. This is because the Linux host needs to resolve the IP when returning the information, if the hosts file in the Linux host is added to the client's IP address in advance, then telnet to Linux from the client will become very fast.   NOTE: The remote login here is not just ssh, it may be MySQL remote login, or file sharing query.   4.2 Dual-machine interconnect   When two hosts are connected, both hosts need to set their own IP and add their own IP and hostname to the hosts file.   5. Host name modification tool hostname;   In fact, the hostname modification also has a special tool, that is hostname   hostname:show or set the system ' s host name   display hostname:   [[EMAIL PR Otected] ~]# hostname  aeolus1   Host name of this host is AEOLUS1, no parameter is used to display the host name of the current host;   temporarily set host name: # hostname Aeolus   via H Ostname tool to set the hostname is only temporary, the next time you restart the system, this host name will not exist;   Display host IP:   [[email protected] ~]# hostname-i  192.168.102.136

Linux/etc/hosts File role

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.