I'm studying networking and having a blast, but the thing is I often plug in a new interface, put it into monitor mode, start capturing with it, unplug it, move it to my laptop, raspberry pi... and have to cope with all the pesky names that each time they receive from the kernel (or systemd I should say).
I'm not too familiar with adding rules in systemd and tbh I found almost none to take inspiration from in my default install here in Garuda (my main distro on all my machines).
Looking around I found something in /usr/lib/systemd/network/99-default.link from which I quote:
To make local modifications, one of the following methods may be used:
copy this file into /etc/systemd/network or one of the other paths checked
by systemd-udevd and edit it there.
This file should not be edited in place, because it'll be overwritten on upgrades.
Can you help me create this rule and explain me all the fields I need to edit or comment out? Like, I get what 'OriginalName' means, but where to put the 'modified name'? And what do all those rules mean in the 'AlternativeNamesPolicy' field?
So far I'm using a shell script but that's very inconvenient since I need to stop all the networking daemons first, rename the interfaces and restart the daemons. Not happy about it. Any other way to achieve the same result without adding a new rule?
Ok I need to spew out another bunch of words because life be tough.
What I wanted to achieve was basically to assign a fixed easy-to-read&remember name to each and every card I own across multiple machines. So that wherever I plug my 'omni alfa card' it's always gonna be (say) 'myalfa0', while my 'directional alfa card' was always gonna be (say) 'myalfa1', and my pc wifi 'mywlan0' and my pc eth 'myeth0' or whatever. This was of course to facilitate writing scripts and few other reasons.
So far... not so good. Meaning: I managed to assign easy&readable names to my cards but I cannot make them match their actual MAC address because they are all USB (except wlan0 which is PCI) and so their MAC address is... 'funny'. Basically even with this new naming system whatever is plugged in first via USB will be (say) 'alfa0' and whatever is second will be 'alfa01'.
So, all in all I can say that using the kernel parameter 'net.ifnames=0' is by far the easiest and most 'portable' solution. But I still believe that there's a way to do what I wanted via the systemd rules. Let's keep diggin then
So, for those who managed to read all this, I have a present for you! This is the line I perfected for the USB recognition via udev. Trust me, it's a bunch of times better than the one in the wiki
Just for future reference I leave here some links that I found and that have been useful to understand a couple of things I wasn't aware of about these 'non persistent MAC addresses', but that ultimately didn't really fix what I was trying to do. I'll hopefully have more time to waste on these minor issues one day.