I like the whole idea of persistant names a lot. The only time a (path based) if name should ever change, is if you move it in your system. That is something you control and know when it happens, so you'll deal with it. Changing if names when adding hardware etc is highly annoying so I get the change. Btw, this sorta is a lot more annoying with USB networking hardware, which some of us are doomed to have to use (hp microservers are awesome but have a very limited pci slots).
That said I like where you are going with this:
snake111 wrote:Thank you, I got it sorted as desired!
FYI:
Code: Select all
# cp /lib/udev/rules.d/80-net-name-slot.rules /etc/udev/rules.d/
# nano /etc/udev/rules.d/80-net-name-slot.rules
80-net-name-slot.rules
Code: Select all
ACTION=="remove", GOTO="net_name_slot_end"
SUBSYSTEM!="net", GOTO="net_name_slot_end"
NAME!="", GOTO="net_name_slot_end"
IMPORT{cmdline}="net.ifnames"
ENV{net.ifnames}=="0", GOTO="net_name_slot_end"
NAME=="", ENV{ID_NET_NAME_ONBOARD}=="eno1", NAME="net0"
NAME=="", ENV{ID_NET_NAME_PATH}=="wlp3s0", NAME="net1"
NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"
NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"
NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"
LABEL="net_name_slot_end"
But this _replaces_ the 80-net rule. I mean, when there's an update in /lib it won't get used, if something decides to copy the rule from /lib to /etc its screwed. Having this file renamed to 81 (not 90, as 90 is some rules based on networking, so imo bad) instantly makes it no longer functioning. I guess it is because NAME=="" is now false? isn't the name now eno1?
I tried my udev mojo, but know too little of it. What I would assume, is have /lib/80-net in place and executed as normal (and thus /etc/80-net deleted). Then have an 81-net rule, that should only have:
Code: Select all
ACTION=="remove", GOTO="net_name_slot_end"
SUBSYSTEM!="net", GOTO="net_name_slot_end"
NAME!="", GOTO="net_name_slot_end"
Skip if the nic is removed or its not in the net section, keep that.
Rename to something sensible; done.
Of course this doesn't work any my udev mojo is weak. Why not?
And why oh why can't we just have an alias (symlink even). I'm fine with having wlp3s0 on my system, but from scripts, config etc i just want to name it net1. Net1 simply always points to the right adapter. Nobody thought of this? Really?
anyway, anybody who can help me with my weak udev mojo, and put down the most simple rule that will work? (Not based on mac, mac's can be wrong/changed etc due to modem demands for example, or cheap chinese hardware etc).