配置

1
2
3
4
5
6
7
8
9
#查询 address
ip addr
#查询网关
ip route show
#查询dns
vi /etc/systemd/resolved.conf

#编辑配置文件
vi /etc/netplan/01-network-manager-all.yaml
1
2
3
4
5
6
7
8
9
10
11
12
# Let NetworkManager manage all devices on this system
network:
ethernets:
enp0s8: # 配置的网卡的名称
addresses: [192.168.56.102/24] # 配置的静态ip地址和掩码
dhcp4: false # 关闭dhcp4
optional: true
gateway4: 192.168.56.1 # 网关地址
nameservers:
addresses: [192.168.56.1,114.114.114.114] # DNS服务器地址,多个DNS服务器地址需要用英文逗号分>隔开,可不配置
version: 2
renderer: NetworkManager
1
2
## 生效
sudo netplan apply

作者声明

1
如有问题,欢迎指正!