1、编辑配置文件:sudo vim /etc/netplan/01-network-manager-all.yaml
1)NET模式
//配置NET网络(二选一)和主机的网关配置需要不一致
network: ethernets: ens33: addresses: [192.168.54.129/24] gateway4: 192.168.54.1 nameservers: addresses: [192.168.54.1, 114.114.114.114] dhcp4: no optional: true version: 2
2)桥接模式
//配置桥接网络(二选一) 和主机的IP配置DNS、网关、掩码 需要一致 network: version: 2 ethernets: ens33: dhcp4: no dhcp6: no bridges: br0: interfaces: [ens33] dhcp4: no addresses: [192.168.31.129/24] gateway4: 192.168.31.1 nameservers: addresses: [192.168.31.1, 114.114.114.114]
2、开启网络
sudo netplan --debug apply
3、ping百度
=========================================================
参考:
1)https://www.jianshu.com/p/030862085f85
2)https://blog.csdn.net/qq_36937342/article/details/80876385