配置/etc/network/interfaces已无用
root@ubuntu:~# vim /etc/netplan/50-cloud-init.yaml
network:
ethernets:
eth0:
addresses:
- 192.168.1.72/24
gateway4: 192.168.1.254
nameservers:
addresses:
- 10.8.1.25
search: []
optional: true
version: 2
执行命令 使配置生效
#sudo netplan apply
-------------------------------------------------------------
配置/etc/network/interfaces
root@ubuntu:~# vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
root@ubuntu:~#vim /etc/resolv.conf
nameserver 114.114.114.114
sudo /etc/init.d/networking restart