配置主机名
vim /etc/hostname
hostname文件中的内容就是主机名,直接修改。
配置hosts文件
vim /etc/hosts
文件内容如下,其中已有内容是对本机地址的映射
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
需要映射的ip地址添加到文件末尾即可
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.8.241 win11
使用ping命令进行测试
[root@linux etc]# ping win11
PING win11 (192.168.8.241) 56(84) bytes of data.
64 bytes from win11 (192.168.8.241): icmp_seq=1 ttl=128 time=0.320 ms
64 bytes from win11 (192.168.8.241): icmp_seq=2 ttl=128 time=0.310 ms
64 bytes from win11 (192.168.8.241): icmp_seq=3 ttl=128 time=0.291 ms