Modify the network card name in linux

Keywords: network Linux

How to modify the network card name in linux

  • Use the ip add or ip link command to view the network interface details
[root@centos6 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3d:56:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.27.128/24 brd 192.168.27.255 scope global eth0
    inet6 fe80::20c:29ff:fe3d:5658/64 scope link 
       valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 52:8f:9d:89:cb:a1 brd ff:ff:ff:ff:ff:ff
4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3d:56:62 brd ff:ff:ff:ff:ff:ff
    inet 172.18.16.20/16 brd 172.18.255.255 scope global eth1
    inet6 fe80::20c:29ff:fe3d:5662/64 scope link 
       valid_lft forever preferred_lft forever


  • It can be seen from the above that there is a network card named eth1. Change the name to the name of GOOD

operation
  1. First, modify / etc / udev / rules. / 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:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3d:56:58", ATTR
{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3d:56:62", ATTR
{type}=="1", KERNEL=="eth*", NAME="GOOD"  # Find the corresponding physical address of eth1, modify the field in the name of this section to become the one you want
  1. Since the modification does not take effect immediately, it will take effect after restart. If you do not want to restart the configuration file, the way to make it effective is to uninstall the network card driver and then reinstall it
  2. How to view the network card driver, using ethtool -i eth1
[root@centos6 ~]# ethtool -i eth1
driver: e1000  #This line is driven by e1000
version: 7.3.21-k8-NAPI
firmware-version: 
bus-info: 0000:02:05.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no
[root@centos6 ~]# 
  1. Uninstall modprobe -r e1000,
[root@centos6 ~]# modprobe -r e1000
 This requires special attention. Since we use the same type of network card, so the driver is the same
 Although there are two network cards, but they are the same, so you can't access the Internet or connect remotely after uninstalling!!!!
  1. Since the network card driver is uninstalled, we need to operate on the local host, and install modprobe e1000 on the network card driver
[root@centos6 ~]# modprobe -r e1000
[root@centos6 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 52:8f:9d:89:cb:a1 brd ff:ff:ff:ff:ff:ff
5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3d:56:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.27.128/24 brd 192.168.27.255 scope global eth0
    inet6 fe80::20c:29ff:fe3d:5658/64 scope link 
       valid_lft forever preferred_lft forever
6: GOOD: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3d:56:62 brd ff:ff:ff:ff:ff:ff
    inet 172.18.16.20/16 brd 172.18.255.255 scope global GOOD
    inet6 fe80::20c:29ff:fe3d:5662/64 scope link 
       valid_lft forever preferred_lft forever
[root@centos6 ~]# 
  1. In this way, it can take effect without restarting.

Posted by detalab on Mon, 01 Jun 2020 08:46:58 -0700