Functions of linux/etc/hosts files

Source: Internet
Author: User
Linux/etc/hosts file function 1. for details about/etc/host, host name and IP configuration file Hosts: Thestatictablelookupforhostname (host name query static table) in Linux,/etc/hosts is the file that configures the IP address and its corresponding host name, here we can... linux/etc/hosts file function 1. about/etc/host, host name and IP configuration file Hosts: The static table lookup for host name (host name query static table) in Linux,/etc/hosts is the file that configures the ip address and its corresponding host name. here, the ip addresses of the local host or other hosts and their corresponding host names can be recorded. This configuration file may be different for different linux versions. For example, Debian's corresponding file is/etc/hostname. 2. the configuration file can be used to configure the host ip address and the corresponding host name. The role of this file on a server-type linux system cannot be ignored. On a LAN or INTERNET, each host has an ip address, which separates each host and can communicate with each other based on the ip address. But the IP address is not easy to remember, so there is a domain name. In a LAN, each machine has a host name, which is used to distinguish hosts for mutual access. The configuration file for the Linux host name is/etc/hosts. this file tells the host which domain names correspond to those ip addresses and which ip addresses correspond to those host names: for example, the file contains the definition 192.168.102.136 dbfan aeolus. suppose 192.168.102.136 is a website server, and enter http://dbfan Or http://aeolus The web page of 192.168.102.136/is opened. Dbfan is a domain name, and aeolus is a host name alias. Generally, this file records the local ip address and host name: 127.0.0.1 localhost. localdomain localhost 3. configuration File Format Description: the content of/etc/hosts is generally similar to the following: 127.0.0.1 localhost. localdomain localhost 192.168.102.136 aeoluspu.com aeolus in general, every action of the hosts file is a host. each line consists of three parts, each of which is separated by spaces. The line starting with # is not explained by the system. First part: network IP address; Second part: host name or domain name; third part: host name alias; of course, each line can also be two parts, namely host IP address and host name; for example, 192.168.102.136 aeoluspu.com. Here we can slightly explain the differences between the host name (hostname) and Domain name (Domain): the host name is usually used in the LAN. through the hosts file, the host name is resolved to the corresponding ip address; the domain name is usually used on the internet, but if the local machine does not want to use domain name resolution on the internet, then you can change the hosts file and add your own domain name resolution. 4. the/hosts file can be used to solve the problem. 4.1 Remote logon to linux hosts is slow. sometimes the client wants to remotely log on to a linux host, but it will wait for a long time before entering the password, this is because the ip address needs to be resolved when the linux host returns information. if you add the client ip address to the hosts file of the linux host, then remote logon from the client to linux will become very fast. Note: remote logon is not only about ssh, but also about mysql remote logon or file sharing query. 4.2 Dual-host interconnection when the two hosts are only dual-host interconnection, then both hosts need to set their own ip addresses and add their own ip addresses and host names to the hosts file of the other host. 5. host name modification tool hostname; in fact, there is also a dedicated tool for modifying the host name, that is, hostname: show or set the system's host name display host name: [root @ aeolus1 ~] # Hostname aeolus1 the host name is aeolus1 and is used to display the host name of the current host without parameters. the host name is set temporarily: # hostname aeolus uses the hostname tool to set the host name to be temporary, the host name will not exist the next time you restart the system. the host IP address is displayed as [root @ aeolus1 ~]. # Hostname-I 192.168.102.136
Related Article

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.