The nomenclature of interfaces has changed a lot in Linux. Sometimes they were called ethN depending on the medium, sometimes according to the driver with enpXsXX and so on. All this is quite cumbersome, especially when the machine is going to perform routing or filtering functions. In these cases it is necessary to have it quite clear at first glance. For that nothing better than being able to change these names according to our particular needs.

In this example, having a machine that will perform perimeter functions, we will need to change the interface names to some more descriptive ones. The method could not be simpler.

Topology

topology

Quite simple, it does not have much to explain.

Initial

Initially the machine provides us with the following interface names.

root@debian-12:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:00:00:01:00 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 192.168.2.254/24 brd 192.168.2.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::250:ff:fe00:100/64 scope link 
       valid_lft forever preferred_lft forever
3: ens4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:50:00:00:01:01 brd ff:ff:ff:ff:ff:ff
    altname enp0s4
4: ens5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:50:00:00:01:02 brd ff:ff:ff:ff:ff:ff
    altname enp0s5

Modification

Now we can insert one file per interface in the /etc/systemd/network/ directory as follows:

root@debian-12:~# cat <<< "[Match]
MACAddress=00:50:00:00:01:00
[Link]
Name=inet
" > /etc/systemd/network/10-ens3.link

This will cause the device manager to rename this interface at the next boot.

Final

So we will get something like the following (once all the files to rename have been added).

root@debian-12:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: inet: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:00:00:01:00 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 192.168.2.254/24 brd 192.168.2.255 scope global inet
       valid_lft forever preferred_lft forever
    inet6 fe80::250:ff:fe00:100/64 scope link 
       valid_lft forever preferred_lft forever
3: lan: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:50:00:00:01:01 brd ff:ff:ff:ff:ff:ff
    altname enp0s4
4: dmz: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:50:00:00:01:02 brd ff:ff:ff:ff:ff:ff
    altname enp0s5

Be careful! You must also remember to modify /etc/network/interfaces or you will be left without connectivity after the reboot.