beta-tester / RPi-PXE-Server

setup a Raspberry Pi as an PXE-Server
307 stars 63 forks source link

Simplify Network interface names #17

Closed squadramunter closed 5 years ago

squadramunter commented 5 years ago

Hi, I see that your code is specific to a interface name. However your code can be much simpler by using this line.

ethernet=basename -a /sys/class/net/* | grep 'eth\|ens\|enp'

wifi=basename -a /sys/class/net/* | grep 'wlan\|wlx\|wlp'

The code is not showing as it pretends to be because github thinks it is code and removes the ` sign

By using this it doesn't matter what the interfaces on the Raspberry client is. You can set this as a variable for all the config files you want to insert.

You may want to take a look at my Routing script from Wireless to Ethernet.

https://github.com/squadramunter/network_routing/blob/master/setup

I created this script to run on every Debian based Linux distro.

beta-tester commented 5 years ago

thank you @squadramunter for the suggestion. i only use eht0 as "fallback" in case the script could not find the built-in ethernet interface of the Raspberry Pi. it should catch that build-in interface of the RPi even the interface is named different than eth0. (except of the fallback case)

i am using a RPi with an additional external USB-ehternet-interface and i want to make sure i will catch the right interface for PXE-Server. the external interface i will use for other purpose in my project (testing branch). that's why i did that complicated scripting construct for finding the network interface name.