Skip to content

Commit c06419d

Browse files
committed
Update network interface renaming post
1 parent 3b3f42b commit c06419d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: content/blog/rename-network-iface.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ date = "2024-03-18"
88

99
## Motivation
1010

11-
**NOTE:** This assumes you have root privileges on the machine you will configure.
12-
13-
Depending on the machine and Linux distribution, different network interfaces can and will appear with different names. For example, `eth0`, `eno1`, `ens1`, `enp1s0`, and `enx0c9863d1a379` are all [valid Ethernet interface names](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/ch-consistent_network_device_naming). Whether you like consistency or just want to give your interfaces more meaningful names, `udev` makes renaming network interfaces straightforward.
11+
Depending on the machine and Linux distribution, different network interfaces may appear with different names. For example, `eth0`, `eno1`, `ens1`, `enp1s0`, and `enx0c9863d1a379` are all [valid Ethernet interface names](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/ch-consistent_network_device_naming). Whether you like consistency or just want to give your interfaces more meaningful names, `udev` makes renaming network interfaces straightforward.
1412

1513
This guide generally targets WiFi and Ethernet interfaces, although concepts will apply to other interface types as well (except Bluetooth). It also assumes no pre-requisite software beyond a text editor, although `ethtool` may be useful.
1614

1715
## Before Getting Started
1816

17+
**NOTE:** This assumes you have root privileges on the machine you will configure.
18+
1919
**Proceed with caution.** It's always a good idea to have physical access to the system when performing networking-related or system-level changes. This is especially true for static configurations which largely rely on the interface name. It's possible that changes made here will disable networking.
2020

2121
If you're unfamiliar with using or configuring networking on Linux, I encourage you to familiarize yourself with the [Querying Network Information](@/blog/linux-cmds.md#querying-network-information) and [Managing Networking (Network Manager)](@/blog/linux-cmds.md#managing-networking-network-manager) sections of my Linux command cheatsheet.
@@ -36,21 +36,21 @@ Should neither of these be an option, `ip -d link show` lists the interface's PC
3636

3737
### 2\. Create the udev Rule
3838

39-
Similar to my post on [configuring USB serial ports details](@/blog/usb-serial.md#3-create-the-udev-rule) details, we'll now create a udev rule to rename the device.
39+
Similar to my post on [configuring USB serial ports details](@/blog/usb-serial.md#3-create-the-udev-rule) details, we'll create a udev rule to rename the device.
4040

4141
#### udev Background
4242

43-
The tl;dr of udev rules for the unfamiliar is that `udev` is a daemon program that runs on many Linux distributions to manage and configure devices.
43+
To be brief, `udev` is a daemon program that runs on many Linux distributions to manage and configure devices.
4444

45-
When configuring a device, be it a network interface or otherwise, `udev` iterates through the rules available on the system pattern matching. Should the rule match, `udev` will perform an action. These actions vary from renaming the network interface to running a custom script.
45+
When configuring a device, be it a network interface or otherwise, `udev` iterates through the rules available on the system pattern matching as it goes. Should the rule match, `udev` will perform the action defined in the matched rule. Distributions generally come with a number of pre-configured rules ready to use on first boot. It's generally a good idea to not touch these, though.
4646

47-
Distributions generally come with a number of pre-configured rules ready to use on first boot. It's generally a good idea to not touch these, though. On my Ubuntu and Fedora machines, these are available in `/usr/lib/udev/rules.d/` and `/usr/local/lib/udev/rules.d/`.
47+
With that said, **the name of the udev rule file matters**. Udev processes rules in lexically sorted order. As all installed rules on the system (including the ones provided by your distribution) are sorted and processed together, it's essential to name the udev rule file with this in mind. Doing so ensures that the new rule does not conflict with other system rules.
4848

4949
#### Configuring the udev Rule
5050

51-
With your MAC addresses and desired network interface names handy, create a rule in `/etc/udev/rules.d` of the format `XX-name.rule`, where `XX` is some positive number. Note that the higher the number here, the lower the priority of the rule when `udev` attempts to pattern match.
51+
With your MAC addresses and desired network interface names handy, create a rule in `/etc/udev/rules.d` of the format `XX-name.rules`, where `XX` is some positive number. Note that the higher the number here, the later udev processes this rule.
5252

53-
On my systems, I use `70`, as this comes before most of the pre-configured `udev` network interface configuration rules (ensuring the name I configure isn't ignored and doesn't potentially cause issues later).
53+
On my systems, I use `70`, as this comes before most of the pre-configured `udev` network interface configuration rules.
5454

5555
For example, here is a rule I have on a multi-Ethernet port system I use as my home router. It relabels the Ethernet ports from the strange, hardware-based naming scheme (e.g. formats `enpXs0` and `enoX` in a non-intuitive ordering) to names that reflect how they're used. Note that each line is a separate rule.
5656

@@ -70,4 +70,4 @@ To use a similar rule on your system, substitute in the MAC address for the quot
7070

7171
### 3\. Reboot and Validate Names Changed
7272

73-
Unlike USB serial devices, reloading udev rules won't necessarily work to rename the interfaces. A reboot is basically required, especially given networking configuration that typically only happens on startup.
73+
Unlike USB serial devices, reloading udev rules won't necessarily rename the interfaces. A reboot is required, especially given networking configuration that typically only happens on startup.

0 commit comments

Comments
 (0)