CentOS8 修改主机名,配置对应IP

一、查看主机名

使用:hostname、hostnamectl、hostnamectl status

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: abbac1605ed64457bd3b40f1c16b66ff
           Boot ID: 6fb6e6ea31384a3d8a8913d09528ad87
    Virtualization: vmware
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.el8.x86_64
      Architecture: x86-64

二、设置主机名,可以以域名方式
[root@localhost ~]# hostnamectl set-hostname dev1
[root@localhost ~]# hostnamectl
   Static hostname: dev1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: abbac1605ed64457bd3b40f1c16b66ff
           Boot ID: 6fb6e6ea31384a3d8a8913d09528ad87
    Virtualization: vmware
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.el8.x86_64
      Architecture: x86-64

三、配置对应IP

[root@dev1 ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.201 dev1

发布了67 篇原创文章 · 获赞 11 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/haveqing/article/details/105086174