"Go" linux-udev the order of the network interface card

Source: Internet
Author: User

Sometimes it is not clear which card to set when setting the IP card. Can you see it? Yes, I can't.

Plus the fact that you've encountered a problem is the order of the network interface card, do not know how the system is to detect, often after the opening of the Order of chaos, write a letter to ask RedHat they recommend that we can use Udev. to name each device. The concept is simple to identify the current network card sequence.

[email protected] ~]# cat/etc/moprobe.conf
Alias Eth0 TG3
Alias Eth1 e1000e
Alias Eth2 e1000e

At present, my network card is Broadcom-eth0, Intel-eth1/eth2 3 (eth0/eth1/eth2) Fu. Take a look at what information eth0 has stored in udev. You can use the command "Udevinfo" to view it.

[email protected] ~]#Udevinfo-ap/sys/class/net/eth0
Udevinfo starts with the device specified by the Devpath and then
Walks up the chain of the parent devices. It prints for every device
Found, all possible attributes in the UDEV rules key format.
A rule to match, can is composed by the attributes of the device
And the attributes from a single parent device.

Looking at device '/class/net/eth0 ':
kernel== "Eth0"
subsystem== "NET"
sysfs{weight}== "64"
sysfs{tx_queue_len}== "1000"
sysfs{flags}== "0x1003"
sysfs{mtu}== "1500"
sysfs{operstate}== "Up"
sysfs{dormant}== "0"
sysfs{carrier}== "1"
sysfs{broadcast}== "Ff:ff:ff:ff:ff:ff"
sysfs{address}== "00:1a:64:22:04:83"
sysfs{link_mode}== "0"
sysfs{type}== "1"
sysfs{features}== "0x1101a9"
sysfs{ifindex}== "4"
sysfs{iflink}== "4"
sysfs{addr_len}== "6"

Looking at parent device '/devices/pci0000:00/0000:00:1c.1/0000:03:00.0 ':


    id== "0000:03:00.0"
bus== "PCI"
driver== "TG3"
sysfs{broken_parity_status}== "0"
sysfs{enable}== "1"
sysfs{modalias}== "Pci:v000014e4d0000165asv00001014sd00000378bc02sc00i00"
sysfs{local_cpus}== "00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000"
sysfs{irq}== "58"
sysfs{class}== "0x020000"
sysfs{subsystem_device}== "0x0378"
sysfs{subsystem_vendor}== "0x1014"
sysfs{device}== "0x165a"
sysfs{vendor}== "0x14e4"

Looking at parent device '/DEVICES/PCI0000:00/0000:00:1C.1 ':
id== "0000:00:1c.1"
bus== "PCI"
driver== "Pcieport-driver"
sysfs{broken_parity_status}== "0"
sysfs{enable}== "1"
sysfs{modalias}== "Pci:v00008086d0000294asv00000000sd00000000bc06sc04i00"
sysfs{local_cpus}== "00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000"
sysfs{irq}== "209"
sysfs{class}== "0x060400"
sysfs{subsystem_device}== "0x0000"
sysfs{subsystem_vendor}== "0x0000"
sysfs{device}== "0x294a"
sysfs{vendor}== "0x8086"

Looking at parent device '/devices/pci0000:00 ':
id== "pci0000:00"
bus== ""
driver== ""

Udev can be named according to the characteristics of the device, that is to say that the eth0 MAC is "00:1a:64:22:04:83" and we can name our network card according to the information provided by this device. Udev's setup is stored in the/etc/udev/rules.d/ The system already has a file "60-net.rules" that is designed to be a network card preset.

[email protected] ~]# cd/etc/udev/rules.d/

60-net.rules is the rule of the system.

[email protected] rules.d]# ll
Total 248
-rw-r--r--1 root root 515 Sep 17:34 05-udev-early.rules
-rw-r--r--1 root root 920 Dec 06:03 40-multipath.rules
-rw-r--r--1 root root 15647 Sep 17:34 50-udev.rules
-rw-r--r--1 root root 163 Dec 4 05:32 51-dlm.rules
-rw-r--r--1 root root 471 Sep 17:34 51-hotplug.rules
-rw-r--r--1 root root 58016 Oct 2006 60-libsane.rules
-rw-r--r--1 root root 143 Nov 23:48 60-net.rules
-rw-r--r--1 root root 1088 Jul 2006 60-pcmcia.rules
-rw-r--r--1 root root 452 Nov 07:15 60-raw.rules
-rw-r--r--1 root root 8209 Sep 22:39 60-wacom.rules
-rw-r--r--1 root root 129 Sep 00:11 61-uinput-stddev.rules
-rw-r--r--1 root root 214 Sep 00:11 61-uinput-wacom.rules
-rw-r--r--1 root root 1823 Sep 06:20 85-pcscd_ccid.rules
-rw-r--r--1 root root 90-alsa.rules
-rw-r--r--1 root root, Sep 17:34 90-dm.rules
-rw-r--r--1 root root (Oct) 21:20 90-hal.rules
-rw-r--r--1 root root 331 Oct 00:08 90-ib.rules
-rw-r--r--1 root root 107 Sep 17:34 95-pam-console.rules
-rw-r--r--1 root root 292 Dec 03:27 98-kexec.rules
-rw-r--r--1 root root 2319 Jul 9 bluetooth.rules
-rw-r--r--1 root root 590 Dec 02:16 xen-backend.rules

Okay, so now we're going to change the name of the device according to the information provided by "Udevinfo", and I'll name my web card according to the system's driver and PCI Bus sequence. Remember Eth0 's information?
id== "0000:03:00.0"
driver== "TG3"

Other eth1/eth2 are using the same method "Udevinfo" to isolate the ID and Driver

[email protected] rules.d]# VI 60-net.rules
action== "Add", subsystem== "net", import{program}= "/lib/udev/rename_device"
subsystem== "NET", run+= "/etc/sysconfig/network-scripts/net.hotplug"
driver== "Tg3", id== "0000:03:00.0", name= "BCM1"
driver== "e1000e", id== "0000:09:00.0", name= "INTEL0"
driver== "e1000e", id== "0000:09:00.1", name= "INTEL1"

Re-remove and load the module.

[email protected] rules.d]# Rmmod TG3
[Email protected] rules.d]# Rmmod e1000e
[Email protected] rules.d]# modprobe TG3
[Email protected] rules.d]# modprobe e1000e
[Email protected] rules.d]# ifconfig-a|grep-i HWaddr

BCM1 Link encap:ethernet HWaddr 00:1a:64:22:04:83
INTEL0 Link encap:ethernet HWaddr 00:15:17:78:5d:d6
INTEL1 Link encap:ethernet HWaddr 00:15:17:78:5d:d7
Virbr0 Link encap:ethernet HWaddr 00:00:00:00:00:00

You will find that the name has changed according to your needs. The natural way is shoulds you can also depend on the MAC Address.
#KERNEL = = "eth*", sysfs{address}== "00:1a:64:22:04:83", name= "BCM1"
The work has not been completed under the/etc/sysconfig/network-scripts/, or there are stored under the name of the device, you can use the manual way to remove the changes or use the #system-config-network to modify!!

"Go" linux-udev the order of the network interface card

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.