Search:  
Gentoo Wiki

TIP_Rename_Network_Interfaces

Contents

Introduction

If you have a couple network interfaces in your box, it's not very easy to remember which is which. Even with two interfaces (one for LAN, and one for internet) it's much easier if their names are local and net (for example), than eth0 and eth1. It will be described here how to rename network interfaces.

Setting up

All you need to do is to make a few changes in your /etc/conf.d/net and change some in /etc/init.d. Syntax is very simple:

File: /etc/conf.d/net
# if MAC address of your card is 00:11:22:33:44:55
# and you want to change its name to world this is what you should do
rename_001122334455="world"
Note: Make sure that the MAC address is capitalized.

Of course, when you do this, you should use world instead of eth0 (or whatever). So, if you need to use Wikipedia:DHCP with this interface, you should to add following lines into /etc/conf.d/net:

File: /etc/conf.d/net
config_world=( "dhcp" )
Note: It is possible to change one name to another, but it is not recommended. If you use MAC address you always know interface name for sure

Relinking

Now you should change links in /etc/init.d. Until now you should have situation like this (or something similar):

Code: ls -l /etc/init.d/net*
lrwxrwxrwx 1 root root    6 2007-06-12 22:51 net.eth0 -> net.lo
-rwxr-xr-x 1 root root  30K 2007-06-12 22:51 /etc/init.d/net.lo

Because you don't use eth0 interface anymore, we should delete it and add new world interface instead. These are command to perform to do that:

# /etc/init.d/net.eth0 stop
# rc-update del net.eth0
# rm /etc/init.d/net.eth0
# ln -s /etc/init.d/net.lo /etc/init.d/net.world
# rc-update add net.world default
# /etc/init.d/net.world start

If everything went well you successfully changed your interface name. Now, just repeat these steps for every interface.


Troubleshooting

It is possible that your system takes old name first, and after that changes it to new address. In that case your startup script should remain unchanged (/etc/init.d/net.eth0). In such a case check file /etc/udev/rules/70-persistent-net.rules. You will probably find old udev rules. They look something like this:

File: /etc/udev/rules/70-persistent-net.rules
# This file was automatically generated by the /lib64/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.

# PCI device 0x10de:0x0057 (forcedeth)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:11:22:33:44:55", NAME="eth0"

Just delete that line and everything should work just fine.

Retrieved from "http://www.gentoo-wiki.info/TIP_Rename_Network_Interfaces"

Last modified: Fri, 05 Sep 2008 23:12:00 +0000 Hits: 6,078