How can I prevent udevd from renaming eth0 to em1

JD jd1008 at gmail.com
Thu Oct 18 01:49:31 UTC 2012


On 10/17/2012 07:22 PM, Digimer wrote:
> On 10/17/2012 09:18 PM, Digimer wrote:
>> On 10/17/2012 06:24 PM, JD wrote:
>>> Briefly....
>>> $ ifconfig -a
>>> em1       Link encap:Ethernet  HWaddr xx:xx:...etc
>>>
>>> lo        Link encap:Local Loopback
>>>
>>> virbr0    Link encap:Ethernet  HWaddr xx:xx:...etc
>>>
>>> virbr0-nic Link encap:Ethernet  HWaddr xx:xx:...etc
>>>
>>> wlan0     Link encap:Ethernet  HWaddr xx:xx:...etc
>> Ah, I see. On my systems, I get:
>>
>> ===
>> em1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
>>          ether f0:de:f1:fc:65:b3  txqueuelen 1000  (Ethernet)
>> ===
>>
>> So the script says "grab any non-space character up to the colon (foo:).
>> Your now showing a colon, so it fails to match.
>>
>> Try replacing:
>>
>> ===
>> 	if ($line =~ /^(\S+):/)
>> ===
>>
>> With:
>>
>>
>> ===
>> 	if ($line =~ /^(\S+)/)
>> ===
> Strike that, I see that you are also showing the HWADDR on the same
> line, so the whole regex this is going to miss your output.
>
> Skip the script; The main thing is to take the 'em1 ... HWadd:
> aa:bb:cc:dd:ee:ff' and put it in 70-persistent-net.rules as (one line);
>
> SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
> ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="eth0"
>
> Then in you 'ifcfg-eth0' file, set 'DEVICE="eth0"' and make sure there
> is no HWADDR="..." line. Reboot and you should be golden.
>

I did do just that, as also vehemently stated by many other bloggers
I read on other web sites. Unfortunately, IT DOES  NOT WORK!!
Here is what I have in /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", 
ATTR{address}=="00:03:0d:15:2b:9e", ATTR{dev_id}=="0x0", 
ATTR{type}=="1", KERNEL=="eth*", NAME="eth0

and I rebooted several times, and yet still:

$ ifconfig eth0
eth0: error fetching interface information: Device not found
$ ifconfig em1
em1       Link encap:Ethernet  HWaddr 00:....etc
           BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
           Interrupt:19 Base address:0xd800
and

$ dmesg | grep em1
[    5.982317] udevd[219]: renamed network interface eth0 to em1

I posted the logic in udev source code where it decides to rename.
I admit that I do not know the udev code, but there might be a problem
in the values of numbers being passed to udev that are incorrect, like
the interface's device index being > 0
Where is this info being gleaned from and passed to udev?
Also, since the name in the rule file is eth0, how is this part of the 
conditional
     strcmp(event->name, udev_device_get_sysname(dev)) != 0 failing?
In otherwords, udev_device_get_sysname() is returning a name other than 
eth0.

Here is that code segment again:

if (udev_device_get_ifindex(dev) > 0 && 
strcmp(udev_device_get_action(dev), "add") == 0 &&
     event->name != NULL && strcmp(event->name, 
udev_device_get_sysname(dev)) != 0) {
                         char syspath[UTIL_PATH_SIZE];
                         char *pos;

                         err = rename_netif(event);



More information about the users mailing list