Oh Linux… Making Your Network Interfaces Names Less “Goofy”… More Organized… More Reliable… Consistent.

Hello beautiful peoples!

So I followed my own advice and I have installed drivers for my USB wireless card “TP-Link Archer T2U Nano” in Debian-based Linux. Worked like a charm which is fantastic… but then I plugged in the card and rebooted. I was going to configure the connection and I went… “OH HELL NAW… Your name is what now?!

Yes… For some reason instead of some cute and memorememberable (I am sure its a word) interface name like wlan0 or wifi0 the card decided to call itself wlxc006c30307b3.

I blame the celebrities. My USB card thought if it calls itself “SkinnyRiceCake0” or something… it will become famous and will be “in with the in crowd”… Unfortunately I often use terminal aka. command line in Linux and there is no way I will remember that gibberish (or am willing to type that in each time)… SO I decided I will change it.

IF you’re following this tutorial on a REMOTE device with no PHYSICAL access my advice is: DON’T DO IT. Why? IF You change the interface name and reboot You may (probably will) lose the connection to the machine. No connection = no access = game over. Unless You have means of fixing the network configuration when it breaks – learn to live with the weird interface name. Period. You have been warned. I am taking no responsibility for your lost access and messed up configs.

First of all make sure a package called udev is installed.

sudo apt -y install udev

Then figure out what the card’s MAC address is. Use this command:

ip a

and search for link/ether for your device. In my case its c0:06:c3:03:07:b3. Figured out Your mac? Good. Copy / write it down.

Armed with this information use your favourite text editor (as root) and create a udev rule that will change your interface’s wicked ways… What is Your favourite Linux terminal text editor? Let me know in the comments! Mine is mcedit. Why? Maybe because I used to use nc a lot back in the early 90s? I find ncurses in that color scheme appealing and comforting…

sudo mcedit /etc/udev/rules.d/5-rename-network.rules

And add this rule (replace the (c0:06:c3:03:07:b3) MAC Address with the one that your card is using):

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="c0:06:c3:03:07:b3", NAME="wlan0"

And reboot the system.

IF you have more than 1 network interface and you want to rename them all – you can. Just add more udev rules with the MAC Address’ of the other network cards underneath like so…

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="c0:06:c3:03:07:b3", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:25:4b:bd:49:9e", NAME="eth0"

And upon reboot this problem is like a fart in the wind… Gone.

This method could also be used to organize Your interfaces by making the names consistent. What do I mean? I remember a friend of mine sharing a story with me where he was sorting out a router or a firewall box on a budget and was using USB LAN cards as his network interfaces. He had a major problem with this setup. 2 LAN cards, eth0 and eth1. One configured as firewall, the other one as router (I believe). But then whenever he rebooted the cards swapped interface names… eth0 was now eth1 and vice versa. Each time the machine was rebooted it was messing up his configuration.

This, would solve the problem by forcing a consistent nameology… Not a word? Yeah, well, I’m an expert in nameology. If you know – you know…

I hope this helps!

Catch you on the flip side,

AndrzejL

Avatar photo

AndrzejL

“Some men just want to watch the world burn.”

Leave a Reply

Your email address will not be published. Required fields are marked *