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