[systemd-devel] Rename NIC by using dynamic MAC

Greg KH gregkh at linuxfoundation.org
Thu Dec 3 08:57:30 PST 2015


On Thu, Dec 03, 2015 at 08:35:24AM -0800, Aaron_Wright at selinc.com wrote:
> > From: Kaesbauer Michael <Michael.Kaesbauer at krones.com>
> > Hi,
> >  
> > up to now I found no way to write an udev rule which renames a
> > specific NIC by using a MAC address that is returned by a bash
> > script. The reason for getting the MAC address by the bash script is
> > that the renaming NIC rule should be applied to different CPUs (with
> > different MACs).
> >  
> >  ...snip...
> 
> I have a similar problem, wanting to name NICs by location in the box. My udev
> rules use KERNELS, which seems to be consistent for me, maybe it'll work for
> you.
> 
> KERNELS=="0000:02:00.0", NAME="front0"
> KERNELS=="0000:06:03.0", NAME="rear0"
> KERNELS=="0000:06:04.0", NAME="rear1"

That's just the PCI device id, which can, and will, randomly change when
you plug a new device in, or update the bios, or update the firmware, or
the next time you boot on a full moon (I had a machine that would change
the pci order every 10th boot for some unknown reason), or some for some
other random reason.

Don't rely on these values, they will change in the future.

Use something that you know will not change, like the slot number (if
your bios provides that), or the MAC address.

good luck,

greg k-h


More information about the systemd-devel mailing list