ubuntu 网卡名称重命名

ubuntu 网卡名称重命名

参考:https://kb.vmware.com/s/article/1032790

# 查看所有网卡列表
$ ifconfig -a

# 查看网络设备类型的设备配置规则
$ cat /etc/udev/rules.d/70-persistent-net.rules | grep net

# 执行 write_net_rules 脚本,此脚本会更新 /etc/udev/rules.d/70-persistent-net.rules 文件
# "ethN" 指网卡设备名称,例如:"eth0"
# "xx:xx:xx:xx:xx:xx" 指网卡设备的MAC地址,例如:"00:10:f3:5a:96:36"
$ sudo rm /etc/udev/rules.d/70-persistent-net.rules
$ sudo env INTERFACE="ethN" MATCHADDR="xx:xx:xx:xx:xx:xx" /lib/udev/write_net_rules


# 查看网卡名称设备对应的MAC地址
$ ifconfig -a eth0 | grep HWaddr

# 查看网卡名称设备的带宽速率
$ ethtool eth0 | grep "link mode"

# 查看网卡名称设备对应的PCIID
$ ethtool -i eth0 | grep bus

# 查看网卡名称设备对应的驱动
$ ethtool -i eth0 | grep driver

# 查看网卡设备的PCIID
$ lspci | grep -i eth
# 查看PCIID的设备信息
$ lspci -D -n -vvv -s 01:00.0
# 查看指定设备ID的设备信息
$ lspci -D -n -vvv -d 8086:10fb

# 查看系统指定设备信息
$ udevadm info -a -p /sys/class/net/eth0

# 重新加载设备规则配置文件
$ sudo chmod a+x /etc/udev/rules.d/70-persistent-net.rules
$ sudo udevadm control --reload-rules 或 sudo service udev restart

# 重启网络管理服务
# sudo service networking restart
# 编辑网卡配置文件 $ sudo vi /etc/network/interfaces

# 查看系统路由项
$ sudo netstat -nr

# 网络设备信息

-------------------------------------------------------------------------------------- name type MATCHADDR Bandwidth PCIID driver device -------------------------------------------------------------------------------------- eth0 Ethernet 00:13:32:0e:2a:60 1000baseT/Full 0000:05:00.0 e1000e 8086:10d3 eth1 Ethernet 00:13:32:0e:2a:61 1000baseT/Full 0000:06:00.0 e1000e 8086:10d3 eth2 Ethernet 00:13:32:0e:2a:62 1000baseT/Full 0000:07:00.0 e1000e 8086:10d3 eth3 Ethernet 00:13:32:0e:2a:63 1000baseT/Full 0000:08:00.0 e1000e 8086:10d3 -------------------------------------------------------------------------------------- eth4 Ethernet 00:10:f3:5a:96:36 10000baseT/Full 0000:01:00.0 ixgbe 8086:10fb eth5 Ethernet 00:10:f3:5a:96:37 10000baseT/Full 0000:01:00.1 ixgbe 8086:10fb -------------------------------------------------------------------------------------- # 将MAC地址与ethN接口名称相关联 $ sudo vi cat 70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:10d3 (e1000e) --- 05:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:60", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:10d3 (e1000e) --- 06:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:61", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" # PCI device 0x8086:10d3 (e1000e) --- 07:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:62", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" # PCI device 0x8086:10d3 (e1000e) --- 08:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:63", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:f3:5a:96:36", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.1 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:f3:5a:96:37", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5" # 将PCI总线地址与ethN接口名称相关联 $ sudo vi cat 70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:10d3 (e1000e) --- 05:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:05:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:10d3 (e1000e) --- 06:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:06:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" # PCI device 0x8086:10d3 (e1000e) --- 07:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:07:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" # PCI device 0x8086:10d3 (e1000e) --- 08:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:08:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:01:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.1 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:01:00.1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5" # 重新加载设备规则配置文件 $ sudo chmod a+x /etc/udev/rules.d/70-persistent-net.rules $ sudo udevadm control --reload-rules 或 sudo service udev restart


================ End

猜你喜欢

转载自www.cnblogs.com/lsgxeva/p/10944806.html