1.查看本机IP、网卡信息
ifconfig
1.修改配置文件
sudo vi /etc/netplan/*.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
Ethernet: #配置的网卡名称
dhcp4: no #dhcp4关闭
dhcp6: no #dhcp6关闭
addresses: [192.168.0.141/24] #设置本机IP及掩码
optional: true
gateway4: 192.168.0.1 #设置网关
nameservers:
addresses: [192.168.0.1] #设置DNS
设置后重启网卡:
netplan apply / sudo netplan apply
,然后查看
ifconfig
,修改成功
如果提示gateway4失效,则换用下面的配置文件。
network:
version: 2
renderer: networkd
ethernets:
Ethernet:
dhcp4: no
dhcp6: no
addresses:
- 192.168.0.141/24
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses:
- 192.168.0.1
版权声明:本文为qq_40703755原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。