IP,DNS,HostName & /etc/hosts 文件

IP, DNS, HostName


1. IP and DNS

Whether it is a local area network or a wide area network, each host needs to have a network card for network communication.
Each network card has an IP address, IP is used to distinguish the network card, is the address of the network card, it is unique.
No 2 network cards have the same IP address.

But the IP address is not easy to remember.

Hence the domain name.
Domain names are used for public network communication, and each domain name corresponds to an IP.
But an IP can have multiple domain names.

So there is a domain name server, Domain Name Servers (DNS)
DNS is the phone book of the public network, which records the domain name and its corresponding IP.



2. Host name - HostName

host: host, owner
server: service

HostName: the name of this machine

Each
The hostname also appears for ease of memory.
A common place to see is the terminal: [user@hostname] The

hostname can be used for LAN communication.
The configuration file related to the host name: /ect/hosts
/ect/hosts is equivalent to a local local DNS, providing the correspondence between ip and hostname.

Some brothers may say that my hostnames cannot visit each other.
Solution 1:
Let all hosts in the LAN have a /ect/hosts file that contains all hosts.

Solution two:
As the DNS server in the LAN, it is suitable for the situation where there are many hosts in the LAN. 3. What is the relationship between hostname and dns? Question 1: What is the relationship between hostname and DNS? Answer:       They are both used for network communication.       LAN communication: hostname + /ect/hosts       WAN communication: DNS Question 2: If I ping a certain hostname in the LAN, will it go through DNS in the middle? Answer:       If there is this hostname in /etc/hosts, it will not go through DNS query. Otherwise it will go through DNS. Question 3: Why do I ping the hostname of this machine and the IP address I get is 127.0.0.1? Answer:       This is because there is a line in /etc/hosts:       127.0.0.1 localhost http://zqscm.qiniucdn.com/data/20071021195338/index.html -










































Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326177516&siteId=291194637