CentOS7設定主機名和 hosts對映
阿新 • • 發佈:2021-12-21
- 為了方便記憶,可以給 linux 系統設定主機名, 也可以根據需要修改主機名
- 指令 hostname : 檢視主機名
[root@lubenwei1 bin]# hostname
lubenwei1
- 修改檔案在 /etc/hostname 指定
- 修改後,重啟生效
- 在 /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
- 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]#