:: Re: [DNG] if2mac init.d service for…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: tito
日付:  
To: dng
題目: Re: [DNG] if2mac init.d service for persistent network interface names
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