cd /etc/netplan
直接编辑
sudo vi /etc/netplan/00-installer-config.yaml
#network:
# ethernets:
# ens160:
# dhcp4: true
# version: 2
network:
version: 2
ethernets:
ens160:
dhcp4: no
addresses: [172.17.10.23/24]
optional: true
gateway4: 172.17.10.1
nameservers:
addresses: [172.17.10.1]
最后执行
sudo netplan apply