Ubuntu18.04修改主机名和网卡地址

date: 2019-06-26 09:56:04

author :headsen chen

notice :个人原创

1,Ubuntu18.04 设置固定IP:

    

    

2,Ubuntu 18.04 设置主机名

   2.1、 vim  /etc/cloud/cloud.cfg,将preserve_hostname开关设置为true:

          

 2.2 .修改主机名(永久)

     #修改主机名(临时)
     # hostname master

     #修改主机名(永久)
     # vim /etc/hostname
    #然后改为需要的主机名后存盘退出

    #映射主机名
    # vim /etc/hosts
    #192.168.1.xxx 主机名

     reboot
     重启后新的主机名就生效了

  还有一种方法就是:hostnamectl set-hostname  new_name,   然后reboot,发现主机名已经固定了。

猜你喜欢

转载自www.cnblogs.com/kaishirenshi/p/11088260.html