跳转至

Ubuntu18 IP配置

ubuntu18.04配置静态ip

vim /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
     enp3s0: #配置的网卡名称,使用ifconfig -a查看得到
       dhcp4: no #dhcp4关闭
       addresses: [192.168.202.36/24] #设置本机IP及掩码
       gateway4: 192.168.202.1 #设置网关
       nameservers:
         addresses: [192.168.202.1] #设置DNS

ubuntu18.04配置动态ip

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
     enp3s0: #配置的网卡名称,使用ifconfig -a查看得到
       dhcp4: true #dhcp4开启
       addresses: [] #设置本机IP及掩码,空
       optional: true

使配置生效

sudo netplan try

评论