Detailed introduction to linux host name configuration

Detailed introduction to linux host name configuration

1. Configure Linux hostname

Next, configure two centos7 virtual machines, with the host names configured as client and server, and their host IP addresses as 192.168.30.8 and 192.168.30.9 respectively.

Configure the client host

[root@client ~]# vi /etc/sysconfig/network

Add the following content and save:

# Created by anaconda
NETWORKING=yes
hostname=client
 Restart the network:
[root@client ~]# systemctl restart network
[root@client ~]# hostname
client
[root@client ~]#

If it does not work, you can use the following command:

[root@client ~]# hostnamectl set-hostname client

Configure the server host

[root@server ~]# hostnamectl set-hostname server

Restart the network:

[root@server ~]# systemctl restart network
[root@server ~]# hostname
server
[root@server ~]# uname -n
server

2. Configure hostname and IP mapping

Configure the hosts files of client and server

vi /etc/hosts

Add the following content:

192.168.30.8 client
192.168.30.9 server

3. Testing

Test whether the configuration is successful by pinging hostname:

client pings server:

[root@client ~]# ping server -c 3
PING server (192.168.30.9) 56(84) bytes of data.
64 bytes from server (192.168.30.9): icmp_seq=1 ttl=64 time=0.616 ms
64 bytes from server (192.168.30.9): icmp_seq=2 ttl=64 time=0.384 ms
64 bytes from server (192.168.30.9): icmp_seq=3 ttl=64 time=0.566 ms

--- server ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.384/0.522/0.616/0.099 ms
[root@client ~]#

server pings client:

[root@Server ~]# ping client -c 3
PING client (192.168.30.8) 56(84) bytes of data.
64 bytes from client (192.168.30.8): icmp_seq=1 ttl=64 time=0.502 ms
64 bytes from client (192.168.30.8): icmp_seq=2 ttl=64 time=0.678 ms
64 bytes from client (192.168.30.8): icmp_seq=3 ttl=64 time=0.323 ms

--- client ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.323/0.501/0.678/0.144 ms
[root@Server ~]#

After configuring the hostname and IP mapping, you can directly ping the host name instead of pinging the IP address.

4. Configure windows hosts

Configure Windows hosts so that you can access it by host name under Windows.

Edit the C:\Windows\System32\drivers\etc\hosts file and add the following content:

192.168.30.8 client
192.168.30.9 server

save

5. Windows test

C:\Users\10287>ping client -n 3

Pinging client [192.168.30.8] with 32 bytes of data:
Reply from 192.168.30.8: Bytes=32 Time<1ms TTL=64
Reply from 192.168.30.8: Bytes=32 Time<1ms TTL=64
Reply from 192.168.30.8: Bytes=32 Time<1ms TTL=64

Ping statistics for 192.168.30.8:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Estimated round trip time in milliseconds:
    Shortest = 0ms, Longest = 0ms, Average = 0ms

This is the end of this article about the detailed introduction of Linux host name configuration. For more relevant Linux host name configuration content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of Linux host name modification command
  • How to change the host name in Linux
  • How to permanently change the host name in Linux
  • How to modify the network card name and host name in Linux

<<:  IE6/7 is going to be a mess: empty text node height issue

>>:  The new version of Chrome browser settings allows cross-domain implementation

Recommend

Web design skills: iframe adaptive height problem

Maybe some people have not come across this issue ...

Experience of redesigning the homepage of TOM.COM

<br />Without any warning, I saw news on cnB...

Manually implement the two-way data binding principle of Vue2.0

In one sentence: Data hijacking (Object.definePro...

Responsive Web Design Learning (2) — Can videos be made responsive?

Previous episode review: Yesterday we talked abou...

Understand CSS3 FlexBox elastic layout in 10 minutes

Basic Introduction Features Flexbox is a CSS disp...

Why is the scroll bar on the web page set on the right?

Why are the scroll bars of the browsers and word ...

How to implement MySQL master-slave replication based on Docker

Preface MySQL master-slave replication is the bas...

How does MySQL achieve master-slave synchronization?

Master-slave synchronization, also called master-...

Analysis of log files in the tomcat logs directory (summary)

Each time tomcat is started, the following log fi...

Should I use UTF-8 or GB2312 encoding when building a website?

Often when we open foreign websites, garbled char...

JS gets the position of the nth occurrence of a specified string in a string

Learn about similar methods for getting character...

HTML table tag tutorial (34): row span attribute ROWSPAN

In a complex table structure, some cells span mul...

Creative opening effect achieved by combining CSS 3.0 with video

Let me share with you a creative opening realized...