Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the location of hosts in Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what the hosts location in the Linux system is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Hosts is a system file without an extension, and its function is to establish an associated "database" between some commonly used URL domain names and their corresponding IP addresses. When a user enters a URL that needs to be logged in in the browser, the system will first automatically find the corresponding IP address from the Hosts file.

1. Hostname:

Whether on the local area network or INTERNET, each host has an IP address to distinguish between this host and the other host, that is to say, the IP address is the house number of the host.

Public network: IP address is not easy to remember, so there is a domain name. Domain names only exist in the public network (INtERNET). Each domain name corresponds to an IP address, but an IP address can have multiple domain names.

Local area network: each machine has a hostname to make it easy to distinguish between hosts and hosts, so you can set a hostname for each machine so that you can access each other in an easy-to-remember way. For example, we can name each machine according to its function in the local area network.

Configuration file related to hostname: / etc/hosts

2. Hostname profile:

The configuration file for hostname is mostly / etc/hosts

The hosts configuration file is a relatively simple way to map host names to IP addresses. But this mapping is only a mapping of the local machine, which means that each machine is independent and none of the computers can 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 hosts is about the definition of host name (Hostname). Each behavior is a host, each line is made up of three parts, and each part is separated by spaces. The lines at the beginning of the # sign are not explained by the system.

The first part: network IP address.

The second part: host name. Domain name, notice that there is a half-corner point between the hostname and the domain name.

The second part: the host name (host name alias) is actually the host name.

Of course, each line can also be divided into two parts, namely the host IP address and the host name; for example, 192.168.1.195 debian

We have three hosts, each doing different things, one for MAIL server, one for FTP server and one for SMB server, so we can design Hostname in this way.

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

Write the contents of the configuration file above into the / etc/hosts contents of each machine, so that the machines of the three Lans can be accessed through Hostname.

3. The difference between host name (Hostname) and domain name (Domain)

The hostname is the name of the machine itself, and the domain name is used to resolve to IP. But it is worth mentioning that in the local area network, the host name can also be resolved to the IP; for example, we mentioned earlier.

Show hostname:

# Hostname

Root1

The hostname of this host is root1, and no parameters are used to display the hostname of the host for the current operation.

Temporarily set the hostname:

We can use Hostname followed by the hostname, so we can set the hostname of the currently operating host, for example, we want to set the hostname to root2

# Hostname root2

Root2

Setting the hostname through the Hostname tool is only temporary and will not exist the next time the system is rebooted; so if you want to modify the hostname and want to be valid all the time, you should modify the hostname configuration file / etc/hosts as mentioned above.

Display the host IP:

[root@Linuxsir01] # Hostname-I

192.168.10.3

What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.

About what the location of hosts in the Linux system is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report