:: Re: [DNG] Ethernet names revisited
Kezdőlap
Delete this message
Reply to this message
Szerző: Steve Litt
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] Ethernet names revisited
On Sun, 13 Dec 2020 14:20:25 +0100
Antony Stone <Antony.Stone@???> wrote:

> On Sunday 13 December 2020 at 13:02:45, Florian Zieboll via Dng wrote:
>
> > Am 13. Dezember 2020 12:01:39 MEZ schrieb Antony Stone
> <Antony.Stone@???>:
> > > Well, here's the output from "dmesg | grep eth". It shows the
> > > r8169 interfaces being given names eth0, eth1 (the ones I want as
> > > eth1 and eth2), then the tg3 interface gets called eth2 (which I
> > > want as eth0).
> > >
> > > At 6 seconds in, you can see my 70-persistent-net.rules file
> > > kicking in and renaming then to xeth2, xeth1 and xeth0; then
> > > finally at 12 seconds, the second rename in
> > > /etc/network/interfaces sets them back to eth0, eth1 and eth2 in
> > > the order I want them.
> >
> > So have you tried with 'ifnames=1'?
>
> I hadn't, but I've just done so now - it makes no difference - here's
> dmesg:
>
> [    0.000000] Linux version 4.19.0-10-amd64
> (debian-kernel@???) (gcc version 8.3.0 (Debian 8.3.0-6))
> #1 SMP Debian 4.19.132-1 (2020-07-24) [    0.000000] Command line:
> BOOT_IMAGE=/boot/vmlinuz-4.19.0-10-amd64
> root=UUID=9cbc8bd3-4cb8-4ae1-92c5-5a3659e9aed6 ro net.ifnames=1 quiet

>
> [    3.394364] r8169 0000:04:00.0 eth0: RTL8168e/8111e,
> 00:e0:4c:80:21:6b, XID 2c200000, IRQ 30
> [    3.394368] r8169 0000:04:00.0 eth0: jumbo features [frames: 9200
> bytes, tx checksumming: ko]
> [    3.450174] r8169 0000:05:00.0 eth1: RTL8168e/8111e,
> 00:e0:4c:80:21:6c, XID 2c200000, IRQ 31
> [    3.450177] r8169 0000:05:00.0 eth1: jumbo features [frames: 9200
> bytes, tx checksumming: ko]
> [    3.489342] tg3 0000:07:00.0 eth2: Tigon3 [partno(BCM95723) rev
> 5784100] (PCI Express) MAC address 78:ac:c0:f7:89:f7
> [    3.489347] tg3 0000:07:00.0 eth2: attached PHY is 5784
> (10/100/1000Base-T Ethernet) (WireSpeed[1], EEE[0])
> [    3.489350] tg3 0000:07:00.0 eth2: RXcsums[1] LinkChgREG[0]
> MIirq[0] ASF[0] TSOcap[1]
> [    3.489352] tg3 0000:07:00.0 eth2: dma_rwctrl[76180000]
> dma_mask[64-bit] [    6.187233] tg3 0000:07:00.0 xeth0: renamed from
> eth2 [    6.231916] r8169 0000:05:00.0 xeth2: renamed from eth1
> [    6.246745] r8169 0000:04:00.0 xeth1: renamed from eth0

>
> > And are you sure, that the 'hwaddress' lines in your
> > '/etc/network/interfaces' really define which NIC to use?
>
> I'm not using hwaddress in that file - that was a suggestion from
> terryc, and I think it's the wrong idea for exactly the following
> reason:
>
> > AFAICT this option just changes ("spoofs") the MAC address of the
> > NIC for which it is defined. Although the log confirms that finally
> > eth0 is the tg3 NIC, this seems unusual (and very counterintuitive)
> > to me.
>
>
> Thanks,
>
>
> Antony.



Stop the madness! Seriously, life shouldn't be this complicated.
Observe:


================================================
#!/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
====================================================

The preceding shellscript delivers the single wifi dev name when
there's only one wifi dev. If there are more, you'll need to tweak it a
little, but no big deal. You can also change it to find Ethernet
devices by changing the "w" in the for statement to an "e". You could
even assign and export the crazy device names to environment variables
like $eth0 and $wla1.

Boxes with multiple Ethernet or Wifi devices were always a problem,
since back when I started in 1998 and probably a lot before. Back then,
the old pros advised us newcomers never to have Ethernet cards of the
same brand and model, or the naming of Ethernet devices would be
indeterminate. Names like wlEat5hit01 aren't my idea of a good
solution, but except in the case of USB dongles, they're a hell of a
lot better than the old eth0 names, if you use them right.

If we'd grown up with wlEat5hit01 and eno8shit3gg25 and gotten used to
them, we'd scream bloody murder if they were replaced with eth0 and
the like.

Shellscripts like the one in this email can be enhanced to do amazing
things with very little effort.

When you find yourself trying to peer inside black boxes like udev,
eudev, evdev, vdev and the like, perhaps it's time to try something
new. There's a reason Ken Thompson and Dennis Ritchie made UNIX the way
they did, with simple commands to give the user incredible power. It
was for situations like this, so you didn't have to read and possibly
tweak a couple thousand lines of C code, you just made a 20 line
shellscript.

SteveT

Steve Litt
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive