配置文件在/etc/netplan/下面,cd进去看具体文件名,不同的人可能文件名不一样,
vim打开之后一般是
# Let NetworkManager manage all devices on this system
network:
ethernets:
enp0s160: # 配置的网卡的名称
dhcp4: true # 打开dhcp4
renderer: NetworkManager
修改成下面这样
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
dhcp4: false
addresses: [192.168.1.105/24] #ip和掩码
optional: true
gateway4: 192.168.1.1 #网关
nameservers:
addresses: [192.168.1.1,144.144.144.144] #DNS服务器
version: 2
renderer: NetworkManager
然后应用
sudo netplan apply