1.查看网卡名称及IP
ip addr
网卡名称:ens33
IP:192.168.44.130
2.修改配置文件
在 /etc/netplan/ 目录下找到配置文件 *.yaml ,修改为
network:
version: 2
#renderer: NetworkManager
ethernets:
ens33:
addresses: [192.168.44.130/24]
dhcp4: no
optional: true
routes:
- to: default
via: 192.168.44.2
nameservers:
addresses: [114.114.114.114]
network:
version: 2
#renderer: NetworkManager
ethernets:
ens33: #配置的网卡的名称
addresses: [192.168.44.130/24] #配置的静态ip地址和掩码
dhcp4: no #关闭DHCP,如果需要打开DHCP则写yes
optional: true
routes:
- to: default
via: 192.168.44.2 #网关地址
nameservers:
addresses: [114.114.114.114] #DNS服务器地址,多个DNS服务器地址需要用英文逗号分隔开
3.应用配置
netplan apply
4.配置不生效?
可能是网卡名称未作修改