You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/rename-network-iface.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ date = "2024-03-18"
8
8
9
9
## Motivation
10
10
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.
14
12
15
13
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.
16
14
17
15
## Before Getting Started
18
16
17
+
**NOTE:** This assumes you have root privileges on the machine you will configure.
18
+
19
19
**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.
20
20
21
21
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
36
36
37
37
### 2\. Create the udev Rule
38
38
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.
40
40
41
41
#### udev Background
42
42
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.
44
44
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.
46
46
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.
48
48
49
49
#### Configuring the udev Rule
50
50
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.
52
52
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.
54
54
55
55
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.
56
56
@@ -70,4 +70,4 @@ To use a similar rule on your system, substitute in the MAC address for the quot
70
70
71
71
### 3\. Reboot and Validate Names Changed
72
72
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