# random MAC adress and udev rule

## mkay

hi,

i'm "happy" nvidia eth card owner, which runs with module forcedeth and each time i load it, i've got a random MAC set. dmesg tells me:

```

forcedeth: using HIGHDMA

0000:00:14.0: Invalid Mac address detected: 95:53:a4:36:16:00

Please complain to your hardware vendor. Switching to a random MAC.

```

i really need fixed adress, couse it's a laptop, which i often use in diffrent locations (and i have dhcp server in all of them), so i've tried to configure udev to always set the same mac. so far i've tried few rules, but none of them work;/ currently i've got that:

```

<root@benek>~: grep eth /etc/udev/rules.d/70-persistent-net.rules |grep -v ^#

SUBSYSTEM=="net", DRIVERS=="?*", KERNEL=="eth*", ATTRS{address}:="00:16:36:A4:53:95"

```

(which doesn't work as well;>)

How should that rule looks like?

----------

## PaulBredbury

I'm not sure that udev can set the MAC address. But, find a method of identifying the card, with:

```
udevinfo -a -p /sys/class/net/eth0
```

It should be ATTR rather than ATTRS, if it's even possible to set the MAC address, according to man udev.

----------

## mkay

 *PaulBredbury wrote:*   

> I'm not sure that udev can set the MAC address. But, find a method of identifying the card, with:
> 
> ```
> udevinfo -a -p /sys/class/net/eth0
> ```
> ...

 

hmm - it's a bit strange, couse i copied ATTRS from rules i've already got automatically created by udev. however you've right - udevinfo shows MAC in ATTR - worth to try

if changing MAC with udev is not possible, then what would be the best method to set it?

i'm thinking about setting name with udev (sometimes, but not always, i get eth1, eth2, eth3.. and so on instead of eth0 when mac is changing) and then use mac_eth0 in /etc/conf.d/net. is there nicer way? (i mean - to set it only in one place)

----------

## PaulBredbury

Call it e.g. wlan.

I'm not sure about changing the MAC.

----------

## alien

Hi,

I have the same problem. My nvidia onboard network card get at every start a new MAC address!  :Smile: 

Therefore  the /etc/init.d/net.eth0 don't start properly, because the network interface is sometimes eth1, eth3, eth4, eth5... and so on.

How to solve this problem or does anybody have a solution for this?

Many thanks!

----------

## alien

Found a possible solution by editing /etc/udev/rules.d/75-persistent-net-generator.rules

From:

```
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS!="xen",  KERNEL=="eth*|ath*|wlan*|ra*|sta*",  NAME!="?*", RIVERS=="?*", GOTO="persistent_net_generator_do"
```

To:

```
#ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS!="xen",  KERNEL=="eth*|ath*|wlan*|ra*|sta*",  NAME!="?*", RIVERS=="?*", GOTO="persistent_net_generator_do"
```

It works, but maybe it's dirty.

----------

## LCISTech

It's a dirty fix, but it worked for my on-board nVidia NIC... wish I had known about this before re-installing my system (although knowing I had upgraded udev just before this problem reappeared helped.)

 *alien wrote:*   

> Found a possible solution by editing /etc/udev/rules.d/75-persistent-net-generator.rules
> 
> From:
> 
> ```
> ...

 

----------

## dev-urandom

 *LCISTech wrote:*   

> It's a dirty fix, but it worked for my on-board nVidia NIC... wish I had known about this before re-installing my system (although knowing I had upgraded udev just before this problem reappeared helped.)
> 
>  *alien wrote:*   Found a possible solution by editing /etc/udev/rules.d/75-persistent-net-generator.rules
> 
> From:
> ...

 

This happens because udev tries to remember the states of the cards and re-initialize them on the next reboot, which could be useful if your configuration is more or less volatile. I've been having the problem too, and it is because forcedeth detects the mac address in the reverse in my case (this should be the same with you too most probably). I've had fairly good success modifying the kernel source to check for the mac address in the reverse, but 2.6.19 has a new version of the driver which according to the comments inside the source fixes the issue. I haven't been able to circumvent the issue, so I ended up commenting out the stuff inside udev. I'll keep looking later, and if i find the problem, i'll post an updated patch for you.

----------

## guyr

Just wanted to let you know that I found this thread handy in an entirely different context.  I just started working with VMWare on Windows XP running Gentoo as a guest.  Worked fine with a preconfigured VM I downloaded from a site referenced here: http://gentoo-wiki.com/HOWTO_Install_Gentoo_on_VMware_in_Windows_NT/2K/XP.  However, when I copied that running instance to a different directory so I could modify it, whenever I tried to start it Gentoo complained that eth0 was not defined.  I found a relevant article on the VMWare forums using Google here:

http://www.vmware.com/community/message.jspa?messageID=478094

So I knew I had an issue with a previously stored MAC address, but where to find it in Gentoo?  So I searched the forums and found this thread.  I'm writing all this in case some one else follows in my path.  I had to both comment out the line you identify, and also delete the file 70-persistent-net.rules.  Having done those two things, I can now copy the files and run the instance from a different directory.  

Thanks!

----------

