Ubuntu 16.04
#vi /etc/network/interfaces
auto lo
iface lo inet loopback
auto ens3
iface ens3 inet static
address 192.168.1.1
gateway 192.168.1.254
netmask 255.255.255.0
#重启网卡
#/etc/init.d/networking restart
Ubuntu 18.04
#vi /etc/netplan/50-cloud-init.yaml
network:
ethernets:
ens3:
addresses: [192.168.1.1/24]
gateway4: 192.168.1.254
dhcp4: false
nameservers:
addresses:
- 223.5.5.5
search: []
optional: true
version: 2
#执行生效
#netplan apply
Ubuntu查看当前系统详细版本
#lsb_release -a