1、查看正確的網卡名稱
1 sudo ifconfig -a
因為此圖為虛擬機搭建的,所以網卡名稱為ens33,如果是真機的話則是enp0s**的名字
2、修改netwlpan文件
1 sudo vim /etc/netplwan/50-cloud-init.yaml 2 3 一下為默認配置文件 4 5 # This file is generated from information provided by 6 # the datasource. Changes to it will not persist across an instance. 7 # To disable cloud-init's network configuration capabilities, write a file 8 # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: 9 # network: {config: disabled} 10 network: 11 ethernets: 12 ens33: 13 addresses: [] 14 dhcp4: true 15 optional: true 16 version: 2
修改第12行的網卡名稱和ifconfig -a中的第一個網卡的名稱一樣就可以了。
保存退出
1 :wq! 或 :x 2 reboot
重啟系統,就可以解決了