最近发现在ubuntu系统下多网卡的工控电脑网卡名被内核修改了,网卡3名为eno1
由于某些原因需要修改网卡名称,网上找了一圈,有各种方法
- 修改grub配置,
/etc/network/interfaces
- 使用Netplan 修改配置信息
- 修改
/etc/udev/rules.d/70-persistent-net.rules
尝试全部失败!
经过google查找,找到了一种正确得方法,使用systemd.link
在 /etc/systemd/network/
添加link配置后重启
[Match]
MACAddress=you mac
[Link]
Name=you name
还有可以根据pci标识来匹配,比如我修改第三个网卡名,dmesg|grep -i eth
可以查询出对应的pci
[Match]
MACAddress=pci-0000:03:00.0
[Link]
Name=youname
下图是修改成功后的结果
Hello! I could have sworn I’ve been to this site before but
after browsing through many of the posts I realized it’s new to me.
Regardless, I’m definitely delighted I stumbled upon it and
I’ll be bookmarking it and checking back often!