ubuntu 18IP配置修改/etc/network/interfaces文件不能使其生效,需修改/etc/netplan/下的**.yaml文件。
sudo vi /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3: #配置的网卡名称,使用ifconfig -a查看得到
dhcp4: no #dhcp4关闭
addresses:
- 172.16.16.199/22
- 192.168.8.199/24
#gateway4: 172.16.19.254 #设置网关
routes:
- to: 0.0.0.0/0 #路由
via: 172.16.19.254 #网关
metric: 100 #优先级
- to: 0.0.0.0/0 #路由
via: 192.168.8.254 #网关
metric: 100 #优先级
nameservers:
addresses: [8.8.8.8]
sudo netplan apply
使配置生效
可通过ip addr
查看配置的IP