:: Re: [DNG] if2mac init.d service for…
Pàgina inicial
Delete this message
Reply to this message
Autor: tito
Data:  
A: dng
Assumpte: Re: [DNG] if2mac init.d service for persistent network interface names
On Fri, 25 Dec 2020 10:09:18 -0500
Steve Litt <slitt@???> wrote:

> On Fri, 25 Dec 2020 09:57:43 +0100
> tito via Dng <dng@???> wrote:
>
> > On Thu, 24 Dec 2020 21:11:49 -0500
> > Steve Litt <slitt@???> wrote:
> >
> > > On Thu, 24 Dec 2020 16:32:18 +0100
> > > tito via Dng <dng@???> wrote:
> > >
> > > > On Thu, 24 Dec 2020 10:10:07 -0500
> > > > Steve Litt <slitt@???> wrote:
> > > >
> > > > > On Wed, 23 Dec 2020 23:41:58 +0100
> > > > > Didier Kryn <kryn@???> wrote:
> > > > >
> > > > > > Le 23/12/2020 à 22:03, Antony Stone a écrit :    
> > > > > > > If the kernel decides A=eth1, B=eth2, C=eth0 then there's
> > > > > > > no way for udev rules to rename them, because "File
> > > > > > > exists" (which should of course say "Device name exists").

> > > > > > >
> > > > > >
> > > > > >     This should not happen and did not happen in the past
> > > > > > because the interfaces are created sequentially.     

> > > > >
> > > > > Yes it did. It happened in the 1900's. We were all advised
> > > > > never to use the same type of network card for both
> > > > > interfaces, because which card became eth0 would be
> > > > > indeterminate. I had eth0 magically switch to eth1, and then
> > > > > back again, several times.
> > > > >
> > > > > Earlier in this thread I submitted a shellscript that fixes
> > > > > this whole problem, without all sorts of udev raindances.
> > > > >
> > > > > SteveT
> > > > >
> > > > > Steve Litt     

> > > >
> > > > Hi,
> > > > is it this one? How does it solve my problem to rename
> > > > interfaces according to their mac address without
> > > > name collisions (plus corner cases)?
> > > >
> > > > #!/bin/sh
> > > > # Copyright (c) 2016 by Steve Litt
> > > > # Expat license. See http://directory.fsf.org/wiki/License:Expat
> > > >
> > > > chosen_wifi_number=${1:-1}
> > > > wifidevs=0
> > > >
> > > > for dev in `ip -o link | sed -n 's/[^:]*: *\(w[^:]*\).*/\1/p'`;
> > > > do
> > > >     wifidevs=`expr $wifidevs + 1`

> > > >
> > > >     test $wifidevs -eq $chosen_wifi_number && {
> > > >     echo $dev
> > > >     exit 0
> > > >     }
> > > > done

> > > >
> > > > echo =max$wifidevs
> > > >
> > > > Ciao,
> > > > Tito
> > >
> > >
> > > It either is the one, or looks a whole lot like it.
> > >
> > > Note that somebody else on this list made it even better, but I
> > > can't find that email again.
> > >
> > > If the "w" in the sed command is changed to "e", then it does the
> > > same thing for wired Ether net.
> > >
> > > The shellscript I wrote spits out one answer. However, it could
> > > easily be modified to do several, either letting you choose, or
> > > perhaps if running exec'ed or dotted, create environment vars like
> > > eth0, eth1, eth2, etc, and wlan0, wlan1, wlan2, etc, so all you
> > > need to do in your shellscripts is change "wlan0" to "$wlan0". As
> > > long as nobody switches slots or jacks, the numbering of these
> > > will be determinate.
> > >
> > > SteveT
> > >
> > > Steve Litt
> > Hi,
> > What I've experienced is that is that even pci bus numbers change
> > from one reboot to the other so unless you tie the names to the mac
> > address they will not be determinate and my router will not work at
> > best and lock me out in the worst case. On a desktop with 1-2 nics
> > or 1 wifi this is not that big problem as the names will stay
> > mostly the same just due to the low numbers involved.
> >
> > Ciao,
> > Tito
>
> That's a good point Tito. What would it take to write a similar
> shellscript using Mac addresses?
>
>
> SteveT
>
> Steve Litt

Hi,
I'm trying to do it and will post version 0.2 asap to review for the
list members, but there is more complexity than you would expect e.g.:

1) interaction with udev: if you change the names you need to 
      produce a net-persistent.rules file so that if you rmmod and
       insmod the names will stay the same;
2) interaction with net.ifnames=0 or 1: system creates new-style names
     but user wants old-style names and didn't set ifnames=0
3) what to do with ifaces renamed in first pass that were not included in if2mac.conf
        (yes have to rename them all or interface swapping will not be possible)
         a) restore original name: not always possible
         b) rename to user style of names and numbering
                  b1) add them to rules file or not
         c) just warn.
 4) make it robust.


This are just a few I recall but there are more.

Ciao,
Tito