[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to compute predictable network interface names?



On 02/23/2017 04:16 PM, Harald Dunkel wrote:
> On 02/16/2017 12:47 PM, Christian Seiler wrote:
>>
>> On a system with predictable names running? Or on a system
>> pre-upgrade?
>>
> 
> Its more "pre-installation". I boot a USB stick and run
> my own installer (using debootstrap or creating a clone).
> The NIC name is needed to setup /etc/network/interfaces.
> I know how the interfaces are named using the old scheme,
> but the predictable names are hard to guess.
> 
>> Because if you have a system that's being upgraded at the
>> moment, the following command _might_ work _after_ you've
>> upgraded udev and _before_ you've rebooted the system.
>>
>> udevadm info /sys/class/net/eth4
>>
>> Look at ID_NET_NAME there.
>>
> 
> I found 3 for eth0 on my desktop PC:
> 
> 	E: ID_NET_NAME_MAC=enx54bef70930bd
> 	E: ID_NET_NAME_ONBOARD=eno1
> 	E: ID_NET_NAME_PATH=enp0s25
> 
> For a server with 6 NICs I got for eth4
> 
> 	E: ID_NET_NAME_MAC=enx0cc47a860566
> 	E: ID_NET_NAME_PATH=enp4s0f2
> 	E: ID_NET_NAME_SLOT=ens261f2
> 
> A wild guess would be it is "ID_NET_NAME_PATH" unless there is
> a "ID_NET_NAME_ONBOARD" ? I understand that this is the fragile
> part.

There's a policy which are going to be preferred. man 5 systemd.link
tells you what the options are and /lib/systemd/network/99-default.link
tells you what the default setting is (the first successful one is
used). On my Stretch system that is:

NamePolicy=kernel database onboard slot path

'kernel' and 'database' are likely going to fail in most cases (kernel
means the kernel indicates that the name used so far is already
predictable, which it only does for very special hardware, probably
embedded or similar, and database means that there's an entry in the
udev hardware database, which you'd have to do manually, because I
don't know of any upstream rules), so basically it's the following
logic:

 - first try ID_NET_NAME_ONBOARD
 - if that doesn't exist, try ID_NET_NAME_SLOT 
 - if that doesn't exist, try ID_NET_NAME_PATH

Regards,
Christian


Reply to: