Network IP Aliasing

Introduction

IP aliasing is a special configuration of your dedicated server network, which enables you to associate several IP addresses to only one network interface .

The aim is to create a virtual interface above eth0, which will be named eth0:0 and will attach the additional IP (or Fail over IP) to your network interface. Here are the explanations for the configuration via SSH. You can also do it directly via your webmin, others section, then files management.

DEFAULT_SERVER_IP:
  The primary IP of your dedicated server.
IP_FAIL_OVER: The Failover IP you want to configure

Requirements

  • A dedicated server
  • IP failover(s)
  • Knowledge about SSH

Applying the configuration

Redhat 7.2, CentOS & Fedora

First we copy the file of eth0 interface and we rename it eth0:0. This will enable you to edit the file in peace:

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

We can now edit the file eth0:0 to replace the IP:

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

First of all, replace the device name, then the existing IP by the failover / additional one that you have received by email:

1
2
3
4
5
6
DEVICE="eth0:0"
ONBOOT="yes"
BOOTPROTO="none" # For CentOS use "static"
IPADDR="IP_FAIL_OVER"
NETMASK="255.255.255.255"
BROADCAST="IP_FAIL_OVER"

Now you just have to assemble the new interface that we have just added:

ifup eth0:0

During a reboot, the interface will automatically be assembled.

If operations 1 to 3 have been correctly carried out, the IP shown in eth0:0 file must be “pingable” from another machine.

If you have several additional IPs, you can do the operation again by using eth0:1eth0:2 and so on.

Gentoo

First, we backup the network configuration file to be able to revert at any time:

cp /etc/conf.d/net /etc/conf.d/net.bak

We can now edit the file to add the ip. Under Gentoo, an alias is directly added in eth0. We don’t create any eth0:0 interface (as under Redhat for example)

Important

The default IP of the server must remain on the same line as config_eth0= in order to make sure that some specific handlings in the network work correctly

After netmask 255.255.255.0, Press Enter and add your IP (DEFAULT_SERVER_IP must obiously be replaced by your server IP)

editor /etc/conf.d/net

You must add:

config_eth0=( "DEFAULT_SERVER_IP netmask 255.255.255.0" "IP_FAIL_OVER netmask 255.255.255.255 brd IP_FAIL_OVER" )

Your /etc/conf.d/net file must contain the following:

1
2
3
4
5
6
7
#This blank configuration will automatically use DHCP for any net.
# scripts in /etc/init.d. To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
config_eth0=( "DEFAULT_SERVER_IP netmask 255.255.255.0"
"IP_FAIL_OVER netmask 255.255.255.255 brd IP_FAIL_OVER" )
routes_eth0=( "default gw DEFAULT_SERVER_IP.254" )

In order to ping your failover IP, you just have to start the network interface again

/etc/init.d/net.eth0 restart

If operations 1 to 3 have been correctly carried out, the IP shown in eth0:0 file must be “pingable” from another machine.

You can therefore insert an additional IP line by line. However, it is important that the default IP remains on the same line as config_eth0.

Debian & derivatives

First, we backup the network configuration file to be able to revert at any time:

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

You must add a secondary interface:

1
2
3
4
auto eth0:0
iface eth0:0 inet static
    address IP_FAIL_OVER
    netmask 255.255.255.255

To make sure the secondary interface(s) is brought up when the eth0 is activated we must add the following line to the eth0 configuration:

1
2
post-up /sbin/ifconfig eth0:0 IP_FAIL_OVER netmask 255.255.255.255 broadcast IP_FAIL_OVER
pre-down /sbin/ifconfig eth0:0 down

So if you had two Failover IPs configured, the /etc/network/interfaces file would look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
auto eth0
iface eth0 inet static
    address DEFAULT_SERVER_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 IP_FAIL_OVER1
    netmask 255.255.255.255

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

    # IPFO 1
    post-up /sbin/ifconfig eth0:0 IP_FAIL_OVER1 netmask 255.255.255.255 broadcast IP_FAIL_OVER1
    pre-down /sbin/ifconfig eth0:0 down

    # IPFO 2
    post-up /sbin/ifconfig eth0:1 IP_FAIL_OVER2 netmask 255.255.255.255 broadcast IP_FAIL_OVER2
    pre-down /sbin/ifconfig eth0:1 down

Restart your network interfaces to activate the new Failover IPs;

/etc/init.d/networking restart

OpenSUSE

First, we backup the network configuration file to be able to revert at any time:

cp /etc/sysconfig/network/ifcfg-ens32 /etc/sysconfig/network/ifcfg-ens32.bak

Then edit the file /etc/sysconfig/network/ifcfg-ens32;

1
2
3
IPADDR_1=Fail.over.IP
NETMASK_1=255.255.255.255
LABEL_1=ens32:0

CPanel

First, we backup the network configuration file to be able to revert at any time:

cp /etc/ips /etc/ips.bak

Edit the file /etc/ips;

editor /etc/ips

Add the ip to the file;

IP_FAIL_OVER:255.255.255.255:IP_FAIL_OVER

Add the ip in /etc/ipaddrpool;

IP_FAIL_OVER

Restart the service managing Failover IPs;

/etc/init.d/ipaliases restart

HG Servers

For HG servers which are delivered with 2 Ip addresses and 2 network cards, it’s necessary to add the failover Ip in the routing rules:

  • SECONDARY_NIC_IP: Initial IP of the secondary Network Interface
  • DEFAULT_SERVER_IP: Initial IP of the server (primary Network Interface)
  • FAILOVER_IP: Your failover IP
1
2
3
4
5
postup() {
    /sbin/ip route add default via SECONDARY_NIC_IP dev eth1 table 223
    /sbin/ip rule add from DEFAULT_SERVER_IP/32 table 223
    /sbin/ip rule add from FAILOVER_IP/32 table 223
}

A example file on a HG server with Gentoo distribution gives:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
This blank configuration will automatically use DHCP for any net.*
scripts in /etc/init.d. To create a more complete configuration,
please review /etc/conf.d/net.example and save your configuration
in /etc/conf.d/net (this file :]!).

config_eth0=( "DEFAULT_SERVER_IP netmask 255.255.255.0"
"DEFAULT_SERVER_IP netmask 255.255.255.255 brd DEFAULT_SERVER_IP.255"
)
routes_eth0=( "default gw DEFAULT_SERVER_IP.254" )
config_eth1=( "FAILOVER_IP netmask 255.255.255.0"
"FAILOVER_IP netmask 255.255.255.255 brd FAILOVER_IP.255"
)

postup() {
    /sbin/ip route add default via SECONDARY_NIC_IP dev eth1 table 223
    /sbin/ip rule add from DEFAULT_SERVER_IP/32 table 223
    /sbin/ip rule add from FAILOVER_IP/32 table 223
}

Windows 2003 Server

First of all, you must add a new device:

  1. Start -> Configuration panel -> New device
  2. Click on “next”, then tick “Yes, I have already connected the device” and “validate
  3. Select the last element of the list: “Add a new device” and “validate

Choose the second option:

  1. Install the device that I select manually in the list (experimented user)” then “validate
  2. Select “Network card” then in the next window, search the “Microsoft producer” and select “Microsoft loopback card

Finish the installation of this device.

By installing the loopback card, a new interface appeared:

  1. Connection to the local network 2” (except for HG servers which have a three interfaces)

It’s now time to add the failover IP address to the interface:

  1. In “Start menu”, select “Configuration panel”, “Network connections” then “Connection to the local network 2
  2. Click on “Properties
  3. Select “Internet Protocol (TCP/IP)
  4. Click on “Properties
  5. Enter the Ip address corresponding to your failover IP and 255.255.255.0 as netmask. Let the others fields empty
  6. Validate all the open windows

Finally you must correct the netmask by 255.255.255.255 but it isn’t allowed by the dialogue box of IP configuration; It’s necessary to modify the information in the registry database:

  1. In “Start menu”, click on “Execute”, then type regedit
  2. Type Ctrl-F3 in order to open the search window, then indicate the failover IP address and click on “Next
  3. Once you found the IP, double-click on “SubnetMask” parameter and change 255.255.255.0 by 255.255.255.255 and “validate
  4. Continue the search by typing F3, do the same modification again
  5. Close the register editor

Finally, to validate the modifications, reboot the interface:

  1. Start”, “Configuration panel”, “Network connections” and do a right click on “Connection to the local network 2” then click on “Desactivate

Wait for few seconds and activate the network connection again.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Network Bridging

Introduction Bridged networking can be used to configure your Virtual Machines. Some tweaking...

Network Configuration

Introduction The network allows two configuration modes for public networking, Bridging and IP...

Disk Replacement

Introduction If you notice that one of your hard drive is failing or that our system notifies...