:: [DNG] Wifi device names: was system…
Top Pagina
Delete this message
Reply to this message
Auteur: Steve Litt
Datum:  
Aan: dng
Oude Onderwerpen: [DNG] systemd is haunting me
Onderwerp: [DNG] Wifi device names: was systemd is haunting me
On Sat, 30 Jan 2016 19:26:48 -0500
Haines Brown <haines@???> wrote:

> I have been running Debian Sid on a laptop with a purged systemd for
> quite a few months. Maybe when I now ran # aptitude update or
> safe-upgrade for the first time after several months since the Sid
> installation systemd-udevd seems to have switched my wireless
> interface from wlan0 to wlp3s0.


I hereby donate the following shellscript to the public domain:

========================================================
#!/bin/sh
if test "$#" == "0"; then
lineno="1"
else
lineno=$1
fi

ip link | \
cut -d ' ' -f2 | \
grep ^w | \
sed -e "s/:\s*$//" | \
head -n $lineno | \
tail -n 1

========================================================

After naming the preceding shellscript get_wifi_dev.sh, I ran it an ip
command diagnostic and get_wifi_dev.sh, and here is what happened:


========================================================
[slitt@mydesk ~]$ ip link | cut -d ' ' -f1-3 | grep "^\S"
1: lo: <LOOPBACK,UP,LOWER_UP>
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP>
3: wlp0s18f2u5: <BROADCAST,MULTICAST>
[slitt@mydesk ~]$ mydev=`get_wifi_dev.sh`
[slitt@mydesk ~]$ echo $mydev
wlp0s18f2u5
[slitt@mydesk ~]$
========================================================

If you suspect you have more than one wifi device, you can specify
which one with a numeric argument to get_wifi_dev.sh, where 1 gets you
the first wifi device reported by ip link, 2 gets the second, and so
on. If your argument is greater than the number of wifi devices, it
just reports the last one reported by ip link.

So regardless of how crazy your wifi device naming gets, you can put
your device's name in a simple and memorable environment variable.

SteveT

Steve Litt
January 2016 featured book: Twenty Eight Tales of Troubleshooting
http://www.troubleshooters.com/28