tharkun
Posts: 2
Joined: Mon Aug 05, 2013 2:37 am

QUESTION: Raspberry Pi Multiple Wireless LAN Adaptors

Tue May 21, 2019 4:15 am

When an external WIFI adaptor is plugged into a Pi and the PI boots, there are 2 network connections listed:
wlan0 and wlan1. The trouble is, it seems to be arbitrary which is assigned to the internal network card, and which is assigned to the external card: sometimes the internal card gets wlan0, and sometimes the external card.

One way round this is to disable the internal network adaptor, then wlan0 will always be the external network adaptor. Problem here is you might need both, for example the external might be in monitor mode with Kismet, and the internal used to wirelessly connect to the Raspberry Pi and read the collected data remotely.

Another way is to switch on predictable network connections or whatever it's called, and get the MAC address of the network adaptor appended to the network connection. I have trouble with this when you use airmon-ng to put the card into monitor mode.

QUESTION: Given a network connection reference like wlan0, is there a way to find out the hardware it's bound to? Ideally, I'd like to write a Python script that would, given a network connection, tell you the hardware it was associated with.

lsusb gives you the connected USB hardware. Would it be possible given this to find by a combination of ifconfig and iwconfig etc, the given WIFI card hardware?

Something like: getWlanHardwareRef("wlan0", "Ralink123.xxxx") true true if wlan0 is bound to a WIFI adaptor with hardware reference "RAlink123.xxxx", false if not.

Then you could call this for all the given network connections available and determine which was the external card.

I'm not asking for the Python script, but a suggestion as to commands that could be called to return the network connection associated with specific USB adaptor hardware.

Any ideas anyone?

Tim

epoch1970
Posts: 3082
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: QUESTION: Raspberry Pi Multiple Wireless LAN Adaptors

Tue May 21, 2019 8:52 am

tharkun wrote:
Tue May 21, 2019 4:15 am
QUESTION: Given a network connection reference like wlan0, is there a way to find out the hardware it's bound to?
Search for "udev"
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Andyroo
Posts: 3377
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: QUESTION: Raspberry Pi Multiple Wireless LAN Adaptors

Tue May 21, 2019 11:15 am

Ifconfig will give you the MAC address and you can tie that back to the hardware.

Note that it will also list the loopback that does not show a MAC address so you will need to skip this.

From memory you can set the Pis MAC address is cmdline.txt if you want to make it really easy for yourself :lol:
Need Pi spray - these things are breeding in my house...

Return to “Networking and servers”