This guide will tell you how to rename or switch network controller names in Linux. Often when installing Linux the installer will automatically pick the names of the network controllers. And for some reason the order it names them is almost always not the order I want them in. I usually like the primary/on-board card eth0, and all additional cards eth1-n, however the installer often has its own ideas. So this is how to correct it!

First off we need to tell the kernel which name gets associated with which physical card. On Debian based systems the information is in /etc/udev/rules.d/70-persistent-net.rules and on Redhat based systems it is in /etc/sysconfig/network-scripts/ifcfg-ethX. You will need to edit those files as root. In each file will be a line for each network controller with its mac address, driver, and name. You want to just edit the name to be what you want. For me that is often just changing eth0 to eth1 and vise-versa. When you are done you may save these files.

Next you need to configure the IP information for the controllers. Edit (as root) /etc/network/interfaces. This file contains the IP address settings for each adapter. If you want eth0 to USE DHCP use:

auto eth0
iface eth0 inet dhcp

If you want to sett-up a static IP address use:

iface eth1 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1

But obviously change the settings to fit your needs.

Now save that file and apply reboot to apply the changes.

Stack Overflow Question on this

Manual temporary configuration

As you should know ifup ethX turns on the network interface and ifdown ethX turns it off, but these only work if the above interfaces file is configured correctly. If the file is configured incorrectly or you want to temporarily use a different configuration you can do so with these commands. Note that the adapter must be in the “down” state before issuing these. you can do this by running “idfown ethX”

ifconfig [device] [static ip ] netmask [network mask] gateway [router ip] up

Or

ifconfig [device] dhcp start

This will bring your current network adapter up with a temporary configuration which will be cleared next time the adapter is brought down (either manually or by a reboot)