On Fri, 25 Dec 2020 09:57:43 +0100
tito via Dng <dng@lists.dyne.org> wrote:

> On Thu, 24 Dec 2020 21:11:49 -0500
> Steve Litt <sl...@troubleshooters.com> wrote:
> 
> > On Thu, 24 Dec 2020 16:32:18 +0100
> > tito via Dng <dng@lists.dyne.org> wrote:
> >   
> > > On Thu, 24 Dec 2020 10:10:07 -0500
> > > Steve Litt <sl...@troubleshooters.com> wrote:
> > >   
> > > > On Wed, 23 Dec 2020 23:41:58 +0100
> > > > Didier Kryn <k...@in2p3.fr> 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 
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to