In a local area network, each machine has a host name to facilitate the distinction between host and host, so set the hostname for each machine to access each other in an easy to remember way. For example, we can name the function of each machine on the LAN
1. Set host name
To view the host name of this computer, use either of the following three commands
# hostname #
Uname-n #
Cat/proc/sys/kernel/hostname
Using the VI Editor to open/etc/hostname files
# Vi/etc/hostname
Delete the original content in the file, add content host Name: Master, save exit
Master
2. Set host name and IP mapping
Using the VI Editor to open/etc/hosts files
# vi/etc/hosts
Add content to the end of the file, format: IP address host name (separated by a space in the middle), save exit
192.168.242.130 Master
Restart the Network service after Setup completes
# systemctl Restart Network
Ping a host name by using the ping command
# ping Master
If you can ping, the setting is successful