Skip to main content

Rename linux network interfaces

Sometimes it can be useful to have network interfaces with an recognizable name, rather than eth0, eth1,… with which you can easily identify to which networks they are connected. For example, if you have a server connected to many networks and vlans you can identify the network/vlan based on interface name, eth50 for vlan50, eth100 for vlan100,… or you can simply rename interface to vlan50, vlan100 directly.

In Debian you should install ifrename package and create the file /etc/iftab with this format:

$ cat /etc/iftab 
eth50  mac F2:A8:C0:77:82:94
eth55  mac 4E:DF:22:FD:71:EA

In Redhat/CentOS you can rename /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-XXXX and edit file specifying this name. For example, I have my ifcfg-eth50 script like this:

DEVICE=eth50
NM_CONTROLLED=yes
ONBOOT=yes
HWADDR=9c:83:4f:af:a1:ec
TYPE=Ethernet
BOOTPROTO=none
IPADDR=172.16.0.19
PREFIX=23
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth50
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
NETMASK=255.255.254.0
USERCTL=no

In Ubuntu, I did not try it but I think you can edit the file /etc/udev/rules.d/70-persistent-net.rules and change the name of interface according to its mac address.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Notice: Undefined variable: wp_sh_class_name in /var/www/elkano.org/blog/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1002

Notice: Undefined variable: wp_sh_class_name in /var/www/elkano.org/blog/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1002

Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /var/www/elkano.org/blog/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048