Free Hosting Online for WorkStations

< Previous | Contents | Next >

7.4.1.2. Creating Custom Udev Rules

The naming scheme can be customized by creating custom Udev rules. A script has been included that generates the initial rules. Generate these rules by running:


bash /lib/udev/init-net-rules.sh

bash /lib/udev/init-net-rules.sh

Now, inspect the /etc/udev/rules.d/70-persistent-net.rules file, to find out which name was assigned to which network device:


cat /etc/udev/rules.d/70-persistent-net.rules

cat /etc/udev/rules.d/70-persistent-net.rules


Note

In some cases such as when MAC addresses have been assigned to a network card manually or in a virtual environment such as Qemu or Xen, the network rules file may not have been generated because addresses are not consistently assigned. In these cases, this method cannot be used.

Note

In some cases such as when MAC addresses have been assigned to a network card manually or in a virtual environment such as Qemu or Xen, the network rules file may not have been generated because addresses are not consistently assigned. In these cases, this method cannot be used.

The file begins with a comment block followed by two lines for each NIC. The first line for each NIC is a commented description showing its hardware IDs (e.g. its PCI vendor and device IDs, if it's a PCI card), along with its driver in parentheses, if the driver can be found. Neither the hardware ID nor the driver is used to determine which name to give an interface; this information is only for reference. The second line is the Udev rule that matches this NIC and actually assigns it a name.

All Udev rules are made up of several keys, separated by commas and optional whitespace. This rule's keys and an explanation of each of them are as follows:


SUBSYSTEM=="net" - This tells Udev to ignore devices that are not network cards.

ACTION=="add" - This tells Udev to ignore this rule for a uevent that isn't an add ("remove" and "change" uevents also happen, but don't need to rename network interfaces).

DRIVERS=="?*" - This exists so that Udev will ignore VLAN or bridge sub-interfaces (because these sub- interfaces do not have drivers). These sub-interfaces are skipped because the name that would be assigned would collide with their parent devices.

ATTR{address} - The value of this key is the NIC's MAC address.

ATTR{type}=="1" - This ensures the rule only matches the primary interface in the case of certain wireless drivers, which create multiple virtual interfaces. The secondary interfaces are skipped for the same reason that VLAN and bridge sub-interfaces are skipped: there would be a name collision otherwise.

NAME - The value of this key is the name that Udev will assign to this interface.

The value of NAME is the important part. Make sure you know which name has been assigned to each of your network cards before proceeding, and be sure to use that NAME value when creating your configuration files below.


Top OS Cloud Computing at OnWorks: