| 74 | | <para>If you are going to use the bus position as the key, find the |
|---|
| 75 | | position of each card with the following commands:</para> |
|---|
| 76 | | |
|---|
| 77 | | <screen role="nodump"><userinput>for dir in /sys/class/net/* ; do |
|---|
| 78 | | [ -e $dir/device ] && { |
|---|
| 79 | | basename $dir ; readlink -f $dir/device |
|---|
| 80 | | } |
|---|
| 81 | | done</userinput></screen> |
|---|
| 82 | | |
|---|
| 83 | | <para>This will yield output similar to:</para> |
|---|
| 84 | | |
|---|
| 85 | | <screen role="nodump"><userinput><replaceable>eth0</replaceable> |
|---|
| 86 | | /sys/devices/pci0000:00/<replaceable>0000:00:0c.0</replaceable> |
|---|
| 87 | | <replaceable>eth1</replaceable> |
|---|
| 88 | | /sys/devices/pci0000:00/<replaceable>0000:00:0d.0</replaceable></userinput></screen> |
|---|
| 89 | | |
|---|
| 90 | | <para>In this example, <replaceable>eth0</replaceable> has PCI bus position |
|---|
| 91 | | <replaceable>0000:00:0c.0</replaceable> (domain 0000, bus 00, device 0c, |
|---|
| 92 | | function 0), and <replaceable>eth1</replaceable> has PCI bus position |
|---|
| 93 | | <replaceable>0000:00:0d.0</replaceable> (domain 0000, bus 00, device 0d, |
|---|
| 94 | | function 0).</para> |
|---|
| 95 | | |
|---|
| 96 | | <para>Now create Udev rules similar to the following:</para> |
|---|
| 97 | | |
|---|
| 98 | | <screen role="nodump"><userinput>cat > /etc/udev/rules.d/70-persistent-net.rules << EOF |
|---|
| 99 | | <literal>ACTION=="add", SUBSYSTEM=="net", BUS=="<replaceable>pci</replaceable>", KERNELS=="<replaceable>0000:00:0c.0</replaceable>", \ |
|---|
| 100 | | NAME="<replaceable>realtek</replaceable>" |
|---|
| 101 | | ACTION=="add", SUBSYSTEM=="net", BUS=="<replaceable>pci</replaceable>", KERNELS=="<replaceable>0000:00:0d.0</replaceable>", \ |
|---|
| 102 | | NAME="<replaceable>intel</replaceable>"</literal> |
|---|
| 103 | | EOF</userinput></screen> |
|---|
| 104 | | |
|---|
| 105 | | <para>Udev has installed a rule_generator rules file that uses MAC |
|---|
| 106 | | addresses, not bus positions. Rules generated by this file will conflict |
|---|
| 107 | | with the rules you just created, so delete the file:</para> |
|---|
| 108 | | |
|---|
| 109 | | <screen role="nodump"><userinput>rm /etc/udev/rules.d/75-persistent-net-generator.rules</userinput></screen> |
|---|
| 110 | | |
|---|
| 111 | | <note> |
|---|
| 112 | | <para>You will also have to remember to create a new bus-position-based |
|---|
| 113 | | rule each time you plug in an additional network card. In a MAC address |
|---|
| 114 | | based persistence scheme, the rule_generator rules file would do this |
|---|
| 115 | | automatically.</para> |
|---|
| 116 | | </note> |
|---|
| 117 | | |
|---|
| 118 | | <para>Regardless of which method you use, these rules will always rename |
|---|
| 119 | | the network cards to <quote>realtek</quote> and <quote>intel</quote>, |
|---|
| 120 | | independently of the original numbering provided by the kernel (i.e.: the |
|---|
| 121 | | original <quote>eth0</quote> and <quote>eth1</quote> interfaces will no |
|---|
| 122 | | longer exist, unless you put such <quote>descriptive</quote> names in the |
|---|
| 123 | | NAME key). Use the descriptive names from the Udev rules instead of |
|---|
| 124 | | <quote>eth0</quote> in the network interface configuration files |
|---|
| 125 | | below.</para> |
|---|
| 126 | | |
|---|
| 127 | | <para>Note that the rules above don't work for every setup. For example, |
|---|
| 128 | | MAC-based rules break when bridges or VLANs are used, because bridges and |
|---|
| 129 | | VLANs have the same MAC address as the network card. One wants to rename |
|---|
| 130 | | only the network card interface, not the bridge or VLAN interface, but the |
|---|
| 131 | | example rule matches both. If you use such virtual interfaces, you have two |
|---|
| 132 | | potential solutions. One is to add the DRIVER=="?*" key after |
|---|
| 133 | | SUBSYSTEM=="net" in MAC-based rules which will stop matching the virtual |
|---|
| 134 | | interfaces. This is known to fail with some older Ethernet cards because |
|---|
| 135 | | they don't have the DRIVER variable in the uevent and thus the rule does |
|---|
| 136 | | not match with such cards. Another solution is to switch to rules that use |
|---|
| 137 | | the bus position as a key.</para> |
|---|
| 138 | | |
|---|
| 139 | | <para>The second known non-working case is with wireless cards using the |
|---|
| 140 | | MadWifi or HostAP drivers, because they create at least two interfaces with |
|---|
| 141 | | the same MAC address and bus position. For example, the Madwifi driver |
|---|
| 142 | | creates both an athX and a wifiX interface where X is a digit. To |
|---|
| 143 | | differentiate these interfaces, add an appropriate KERNEL parameter such as |
|---|
| 144 | | KERNEL=="ath*" after SUBSYSTEM=="net".</para> |
|---|
| 145 | | |
|---|
| 146 | | <para>There may be other cases where the rules above don't work. Currently, |
|---|
| 147 | | bugs on this topic are still being reported to Linux distributions, and no |
|---|
| 148 | | solution that covers every case is available.</para> |
|---|
| | 61 | <itemizedlist> |
|---|
| | 62 | <listitem> |
|---|
| | 63 | <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore |
|---|
| | 64 | devices that are not network cards.</para> |
|---|
| | 65 | </listitem> |
|---|
| | 66 | <listitem> |
|---|
| | 67 | <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will |
|---|
| | 68 | ignore VLAN or bridge sub-interfaces (because these sub-interfaces do |
|---|
| | 69 | not have drivers). These sub-interfaces are skipped because the name |
|---|
| | 70 | that would be assigned would collide with their parent devices.</para> |
|---|
| | 71 | </listitem> |
|---|
| | 72 | <listitem> |
|---|
| | 73 | <para><literal>ATTRS{type}=="1"</literal> - Optional. This key will |
|---|
| | 74 | only be added if this NIC is a wireless NIC whose driver creates |
|---|
| | 75 | multiple virtual interfaces; it ensures the rule only matches the |
|---|
| | 76 | primary interface. The secondary interfaces are not matched for the |
|---|
| | 77 | same reason that VLAN and bridge sub-interfaces are not matched: there |
|---|
| | 78 | would be a name collision.</para> |
|---|
| | 79 | </listitem> |
|---|
| | 80 | <listitem> |
|---|
| | 81 | <para><literal>ATTRS{address}</literal> - The value of this key is the |
|---|
| | 82 | NIC's MAC address.</para> |
|---|
| | 83 | </listitem> |
|---|
| | 84 | <listitem> |
|---|
| | 85 | <para><literal>NAME</literal> - The value of this key is the name that |
|---|
| | 86 | Udev will assign to this interface.</para> |
|---|
| | 87 | </listitem> |
|---|
| | 88 | </itemizedlist> |
|---|
| | 89 | |
|---|
| | 90 | <para>The value of <literal>NAME</literal> is the important part. Make sure |
|---|
| | 91 | you know which name has been assigned to each of your network cards before |
|---|
| | 92 | proceeding, and be sure to use that <literal>NAME</literal> value when |
|---|
| | 93 | creating your configuration files below.</para> |
|---|