Ubuntu18.04网络管理改成netplan方式 ,配置写在/etc/netplan/目录下,类型为xxx.yaml文件,我这里是:
01-network-manager-all.yaml
修改前先确认下自己的网卡名称,输入
ip addr
进行查看
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:2c:30:fa brd ff:ff:ff:ff:ff:ff inet 192.168.174.152/24 brd 192.168.174.255 scope global dynamic noprefixroute ens33 valid_lft 1309sec preferred_lft 1309sec inet6 fe80::3a03:14e5:b956:9894/64 scope link noprefixroute valid_lft forever preferred_lft forever
可以看出我这里就一个,名字叫ens33,接下来进行配置, 打开01-network-manager-all.yaml进修改:
ethernets:
ens33:
addresses:
– 192.168.250.5/24
dhcp4: false
gateway4: 192.168.250.1
nameservers:
addresses:
– 192.168.250.1
search: []
# Let NetworkManager manage all devices on this system network: ethernets: ens33: #网卡名称 addresses: - 192.168.250.5/24 #固定IP地址和网段(子网掩码)或者addresses: [192.168.250.5/24] dhcp4: false #关闭DHCP dhcp6: false gateway4: 192.168.250.1#网关 nameservers: addresses: - 192.168.250.1 #DNS search: [] version: 2 renderer: NetworkManager
测试一下:sudo netplan try
sudo netplan try
生效更改:sudo netplan apply
sudo netplan apply
扩展:
恢复自动获取就把添加的给删了就可以了
重新启停以太网卡命令:
ifconfig ens33 down
ifconfig ens33 up
多网卡配置时,局域网的不要配网关,访问外网的配置正确网关
原文链接:https://blog.csdn.net/nyszx/article/details/124367654
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END