How To Add Multiple IP Addresses On Linux / Fedora Core / Fedora

Angsuman Chakraborty

September 11th, 2007

Most guide to adding multiple IP addresses on Linux starts with the Microsoft-like solution of using ifconfig. While the solution is correct it doesn’t survive a reboot or even a network restart. Here’s how you can easily and permanently add multiple IP addresses to the same (or different) network interface on your Linux machine. I just successfully configured dozens of IP addresses on our new dedicated server using this method. First I will explain how you can add using the Fedora user interface and then from the Linux command line.

How to set multiple IP addresses using the Fedora user interface

Linux supports multiple IP adresses on the same network interface. Adding multiple IP addresses from the user interface in Fedora is simple.

  1. Select menu item System->Administration->Network.
  2. Click on New to add a new IP address
  3. Select Ethernet connection
  4. Select the Ethernet card (in my case it is Intel Corp 82566DC Gigabit Network Connection)
  5. Specify your chosen IP address
  6. Specify subnet mask (if in doubt use 255.255.255.0; better yet ask your system admin)
  7. Specify your gateway, if you have one configured
  8. Click Next and then click on Apply.

Repeat the procedure for all your IP addresses.

Restart the network:

/sbin/service network restart

You are done!

How to set multiple IP addresses using Linux command line

Go to /etc/sysconfig/network-scripts

Make multiple copies of ifcfg-eth0 and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.

Open each of them and at least change the IPADDR to your chosen IP address and the NETMASK to the subnet mask for that IP address.

A sample entry would look like this:

DEVICE=eth0:0

BOOTPROTO=static

IPADDR=34.123.111.21

NETMASK=255.255.255.0

ONBOOT=yes

Restart the network:

/sbin/service network restart

You are done!