Ubuntu20.4静态ip和dhcp配置

一、目录及配置文件:

cd /etc/netplan
vim 01-network-manager-all.yaml

二、静态ip配置方式:

01-network-manager-all.yaml.static

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp4s0:
      dhcp4: false
      addresses: [192.168.50.87/24]
      gateway4: 192.168.50.3
      nameservers:
        addresses: [192.168.50.3,8.8.8.8]

三、DHCP配置方式:

01-network-manager-all.yaml.dhcp

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp4s0:
      dhcp4: true

四、重启netplan:

需要启用哪一种ip分配策略就拷贝文件,并去掉最后的后缀

sudo netplan --debug apply
ip a

Ubuntu20.4静态ip和dhcp配置

上一篇:无法获得锁管理目录(/var/lib/dpkg/),是否有其他进程正占用它


下一篇:Major Stuff about Linux