配置方法Ubuntu和CentOS应该是一样的。
当然查看自己的主机名有两种方式:
1.hostname
命令
2.cat /etc/hostname
接下来修改主机名和IP的映射关系
1.
vi /etc/hosts
2.写入以上这种格式的内容之后,还需要重启网络服务
#版本不同,重启服务的命令不同#Ubuntu16.04sudo service networking restart#Ubuntu18.04sudo netplan apply#CentOSsystemctl restart network
3.接下来你可以做一个测试
例如我这里ping master01
就相当于ping 192.168.17.134
,观察一下是否能够ping通。
如果觉得《Ubuntu/CentOS配置主机名IP映射关系》对你有帮助,请点赞、收藏,并留下你的观点哦!