Additional IPs Setup

Instructions

CentOS and Fedora

Step 1: Create interface file

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

Step 2: Edit the source file

vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

Content of file:

DEVICE="eth0:0"
ONBOOT="yes"
BOOTPROTO="static" # For Fedora use "none"
IPADDR="Additiona_IP"
NETMASK="255.255.255.255"
BROADCAST="Additiona_IP"

Step 3: Bring up the network interface

ifup eth0:0

Repeat for all additional IPs with different DEVICE name and file name eth0:1, eth0:2, etc.


Debian 6/7/8
Step 1: Create interface file

cp /etc/network/interfaces /etc/network/interfaces.bak

Step 2: Edit the interface file

vi /etc/network/interfaces

Add a secondary interface:

auto eth0:0
iface eth0:0 inet static
address ADDITIONAL_IP
netmask 255.255.255.255

To enable when the eth0 interface is also enabled, add the following line to the eth0 configuration:

post-up /sbin/ifconfig eth0:0 ADDITIONAL_IP netmask 255.255.255.255 broadcast ADDITIONAL_IP
pre-down /sbin/ifconfig eth0:0 down

If you have more than one Additional IPs, /etc/network/interfaces should look like:

auto eth0
iface eth0 inet static
address MAIN_IP
netmask 255.255.255.0
broadcast xxx.xxx.xxx.255
gateway xxx.xxx.xxx.254

auto eth0:0
iface eth0:0 inet static
address ADDITIONAL_IP_1
netmask 255.255.255.255

auto eth0:1
iface eth0:1 inet static
address ADDITIONAL_IP_2
netmask 255.255.255.255

# Additional IP 1
post-up /sbin/ifconfig eth0:0 ADDITIONAL_IP_1 netmask 255.255.255.255 broadcast ADDITIONAL_IP_1
pre-down /sbin/ifconfig eth0:0 down

# Additional IP 2
post-up /sbin/ifconfig eth0:1 ADDITIONAL_IP_2 netmask 255.255.255.255 broadcast ADDITIONAL_IP_2
pre-down /sbin/ifconfig eth0:1 down

Step 3: Restart the network interface

/etc/init.d/networking restart

Was this answer helpful?