1 # These rules generate rules to keep network interface names unchanged
2 # across reboots write them to /etc/udev/rules.d/70-persistent-net.rules.
4 # variables used to communicate:
5 # MATCHADDR MAC address used for the match
6 # MATCHID bus_id used for the match
7 # MATCHDRV driver name used for the match
8 # MATCHIFTYPE interface type match
9 # COMMENT comment to add to the generated rule
10 # INTERFACE_NAME requested name supplied by external tool
11 # INTERFACE_NEW new interface name returned by rule writer
13 ACTION!="add", GOTO="persistent_net_generator_end"
14 SUBSYSTEM!="net", GOTO="persistent_net_generator_end"
16 # ignore the interface if a name has already been set
17 NAME=="?*", GOTO="persistent_net_generator_end"
19 # ignore interfaces without a driver link like bridges and VLANs
20 DRIVERS!="?*", GOTO="persistent_net_generator_end"
22 # device name whitelist
23 KERNEL!="eth*|ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", \
24 GOTO="persistent_net_generator_end"
26 # ignore Xen virtual interfaces
27 SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end"
29 # ignore UML virtual interfaces
30 DRIVERS=="uml-netdev", GOTO="persistent_net_generator_end"
32 # ignore "secondary" raw interfaces of the madwifi driver
33 KERNEL=="ath*", ATTRS{type}=="802", GOTO="persistent_net_generator_end"
35 # ignore "secondary" monitor interfaces of mac80211 drivers
36 KERNEL=="wlan*", ATTRS{type}=="803", GOTO="persistent_net_generator_end"
38 # by default match on the MAC address and interface type
39 ENV{MATCHADDR}="$attr{address}"
40 ENV{MATCHIFTYPE}="$attr{type}"
42 # ignore interfaces with locally administered or null MAC addresses
43 # and VMWare virtual interfaces
44 ENV{MATCHADDR}=="?[2367abef]:*", ENV{MATCHADDR}=""
45 ENV{MATCHADDR}=="00:00:00:00:00:00", ENV{MATCHADDR}=""
46 ENV{MATCHADDR}=="00:0c:29:*|00:50:56:*", ENV{MATCHADDR}=""
48 # ibmveth interfaces have stable locally administered MAC addresses
49 SUBSYSTEMS=="ibmveth", ENV{MATCHADDR}="$attr{address}"
51 # S/390 interfaces are matched only by id
52 SUBSYSTEMS=="ccwgroup", \
53 ENV{MATCHDRV}="$driver", ENV{MATCHID}="$id", ENV{MATCHADDR}=""
55 # terminate processing if there are not enough conditions to create a rule
56 ENV{MATCHADDR}=="", ENV{MATCHID}=="", ENV{INTERFACE_NAME}=="", \
57 GOTO="persistent_net_generator_end"
60 # provide nice comments for the generated rules
62 ENV{COMMENT}="PCI device $attr{vendor}:$attr{device}"
63 SUBSYSTEMS=="pcmcia", \
64 ENV{COMMENT}="PCMCIA device $attr{card_id}:$attr{manf_id}"
66 ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct}"
67 SUBSYSTEMS=="ccwgroup", \
68 ENV{COMMENT}="S/390 device at $id"
69 SUBSYSTEMS=="ibmveth", \
70 ENV{COMMENT}="LPAR virtual device at $id"
71 SUBSYSTEMS=="ieee1394", \
72 ENV{COMMENT}="Firewire device $attr{host_id}"
74 ENV{COMMENT}="Unknown $env{SUBSYSTEM} device ($env{DEVPATH})"
75 ATTRS{driver}=="?*", \
76 ENV{COMMENT}="$env{COMMENT} ($attr{driver})"
79 # generate and write the rule
80 IMPORT{program}="write_net_rules"
82 # rename the interface if requested
83 ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}"
85 LABEL="persistent_net_generator_end"