CentOS7设置主机名和 hosts映射

  1. 为了方便记忆,可以给 linux 系统设置主机名, 也可以根据需要修改主机名
  2. 指令 hostname : 查看主机名
[root@lubenwei1 bin]# hostname
lubenwei1
  1. 修改文件在 /etc/hostname 指定
  2. 修改后,重启生效
  3. 在 /etc/hosts 文件 指定
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

#配置服务器的dns
192.168.217.26 lubenwei1
  1. ping 主机名
[root@lubenwei1 bin]# ping lubenwei1
PING lubenwei1 (192.168.217.26) 56(84) bytes of data.
64 bytes from lubenwei1 (192.168.217.26): icmp_seq=1 ttl=64 time=0.069 ms
64 bytes from lubenwei1 (192.168.217.26): icmp_seq=2 ttl=64 time=0.062 ms
64 bytes from lubenwei1 (192.168.217.26): icmp_seq=3 ttl=64 time=0.056 ms
64 bytes from lubenwei1 (192.168.217.26): icmp_seq=4 ttl=64 time=0.090 ms
64 bytes from lubenwei1 (192.168.217.26): icmp_seq=5 ttl=64 time=0.060 ms
^Z
[2]+  已停止               ping lubenwei1
[root@lubenwei1 bin]# 

/ect/sysconfig/network 该文件用来指定服务器上的网络配置信息
HOSTNAME:lubenwei1

posted @ 2021-12-21 21:23  MikiKawai  阅读(263)  评论(0编辑  收藏  举报