CentOS7 set host name and IP mapping

Source: Internet
Author: User

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

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.