1# Renaming network interfaces {#sec-rename-ifs}
2
3NixOS uses the udev [predictable naming
4scheme](https://systemd.io/PREDICTABLE_INTERFACE_NAMES/) to assign names
5to network interfaces. This means that by default cards are not given
6the traditional names like `eth0` or `eth1`, whose order can change
7unpredictably across reboots. Instead, relying on physical locations and
8firmware information, the scheme produces names like `ens1`, `enp2s0`,
9etc.
10
11These names are predictable but less memorable and not necessarily
12stable: for example installing new hardware or changing firmware
13settings can result in a [name
14change](https://github.com/systemd/systemd/issues/3715#issue-165347602).
15If this is undesirable, for example if you have a single ethernet card,
16you can revert to the traditional scheme by setting
17[](#opt-networking.usePredictableInterfaceNames)
18to `false`.
19
20## Assigning custom names {#sec-custom-ifnames}
21
22In case there are multiple interfaces of the same type, it's better to
23assign custom names based on the device hardware address. For example,
24we assign the name `wan` to the interface with MAC address
25`52:54:00:12:01:01` using a netword link unit:
26
27```nix
28systemd.network.links."10-wan" = {
29 matchConfig.PermanentMACAddress = "52:54:00:12:01:01";
30 linkConfig.Name = "wan";
31};
32```
33
34Note that links are directly read by udev, *not networkd*, and will work
35even if networkd is disabled.
36
37Alternatively, we can use a plain old udev rule:
38
39```nix
40services.udev.initrdRules = ''
41 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \
42 ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan"
43'';
44```
45
46::: {.warning}
47The rule must be installed in the initrd using
48`services.udev.initrdRules`, not the usual `services.udev.extraRules`
49option. This is to avoid race conditions with other programs controlling
50the interface.
51:::