Ubuntu18.04的网络配置 netplan

在虚拟机装完 Ubuntu 18.04 LTS,开机无法联网,网卡没有启用。配置网络时发现 ifupdown has been replaced by netplan(5) on this system。
vim /etc/network/interfaces 修改网络配置时发现Ubuntu 18 ifupdown has been replaced by netplan(5) on this system。

配置netplan 固定ip

vim /etc/netplan/50-cloud-init.yaml 

配置如下:
network:
    ethernets:
        enp3s0:
            addresses: [192.168.0.20/24]  //IP址
            gateway4: 192.168.0.1  // 网关
            nameservers:
             addresses: [114.114.114.114, 192.168.0.1] //DNS
            dhcp4: no
            optional: no
    version: 2

或者配置dhcp自动获取ip

vim /etc/netplan/50-cloud-init.yaml 

配置如下:
network:
    ethernets:
        enp3s0:
            dhcp4: true
            optional: yes
    version: 2

应用:

sudo netplan apply

这样以后启动就自动启用网卡了。

你可能感兴趣的:(ubuntu,linux)