rss logo

Renaming Network Interfaces on Debian

Debian logo

On most GNU/Linux distributions, network interfaces are often assigned names that are not intuitive or easy to remember. In this tutorial, we'll learn how to rename a network interface to a custom name on a Debian system, making network management more convenient.

Identifying the Network Interface

Suppose we have two network interfaces, and one of them is connected to the 192.168.1.0/24 network. This is the interface we intend to rename.

  • List all network interfaces and note the associated MAC address of the one you want to rename:
root@host:~# ip addr sh

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 
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 18:1f:64:24:0b:ba brd ff:ff:ff:ff:ff:ff
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether a7:15:ca:4c:1a:13 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic enp2s0
       valid_lft 28998sec preferred_lft 28998sec
    inet6 fe80::6a05:caff:fe39:c153/64 scope link 
       valid_lft forever preferred_lft forever

We’ve identified the network interface we want to rename. Its current name is enp2s0, and we’re going to rename it to lan for easier reference.

Renaming the Network Interface

Now that we’ve identified the MAC address of the network interface we want to rename, we can create a corresponding configuration file.

  • Create the file /etc/systemd/network/10-persistent-net_lan.link with the following content:
[Match]
MACAddress=a7:15:ca:4c:1a:13

[Link]
Name=lan
  • Restart the Debian system to apply the changes:
root@host:~# reboot
  • After the reboot, verify that the new interface name has been applied:
root@host:~# ip addr sh

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 
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 18:1f:64:24:0b:ba brd ff:ff:ff:ff:ff:ff
3: lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether a7:15:ca:4c:1a:13 brd ff:ff:ff:ff:ff:ff
    altname enp2s0
    inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic enp2s0
       valid_lft 28998sec preferred_lft 28998sec
    inet6 fe80::6a05:caff:fe39:c153/64 scope link 
       valid_lft forever preferred_lft forever