beta-tester
Posts: 1593
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

[solved] Raspbian Stretch: how to identify built-in ethernet adapter

Thu Aug 17, 2017 7:24 pm

i have a problem with Raspbian Stretch (2017-07-05-raspbian-jessie.img).
with Raspbian/Debian Stretch the method of naming network adapters has changes.
on Raspbian Jessie the built-in ethernet adapter got always the name eth0.
on Raspbian Stretch the built-in ethernet adapter get a name with the MAC address in it (e.g. enx112233445566).
but this makes it impossible for scripts to find the built-in ehternet adapter without the knowledge of the MAC of that adapter.

in the past, i simply could grab necessary information by using the name eth0.
how can i identify the built-in ethernet adapter without knowing the MAC address and existence of multiple ethernet adapters at the same time.
e.g.

Code: Select all

pi@raspberry:~ $ ifconfig
enx112233445566: ...
enx998877665544: ...
enx556677889900: ...
lo: ...
how can the script find out which of the listed adapters is the built-in adapter of the RPi, when the MAC address is unknown by the script?
(the script is running on different RPis - so i can not hardcode the MAC or adapter name)

PS.: i am not able to do any preparations before the script is running. the script has to work out of the box on each RPi.
Last edited by beta-tester on Sun Aug 20, 2017 11:58 am, edited 2 times in total.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

beta-tester
Posts: 1593
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspbian Stretch: how to identify built-in ethernet adapter

Thu Aug 17, 2017 7:46 pm

hmm... it is ugly, but at the moment i don't find an other solution...
i am fetching the network adapter that sitts on the first USB adapter on the first "port".

Code: Select all

pi@raspberry:~ $ ls /sys/devices/platform/soc/*.usb/usb1/1-1/1-1.1/1-1.1:1.0/net
enx112233445566
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

Return to “Troubleshooting”