配置文件位于 /etc/netplan/
目录下
cd /etc/netplan/
修改配置文件
sudo vi 01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
ens33:
dhcp4: false
addresses: [192.168.94.68/24]
gateway4: 192.168.94.2
nameservers:
addresses: [192.168.94.1,8.8.8.8]
重启 netplan
sudo netplan apply
注:
Invalid YAML: inconsistent indentation:
ethernets:
重启时报如上错误为 yaml 文件的缩进错误。
Error in network definition: expected mapping (check indentation)