Signup
LINUX SYSTEM ADMINISTRATION FORUM
Top Web Hosts >> Forums >> Linux System Administration

   
  Howto: Linux IP aliasing
  Name : aladar     Date : 06-11-13 11:08     Hit : 6545    
On a Linux server, one IP address is typically assigned to a NIC (Network Interface Card), i.e. ethernet card. The IP address assigned to the NIC serves as the primary IP. In a situation where you'll need multiple IP addresses (that connect to a same network), you may use IP aliasing feature of the Linux to map multiple IP addresses to a single NIC.

To set up an IP alias, execute the following command:

# ifconfig eth0:0 192.168.1.3 netmask 255.255.255.0 up

This assigns the IP address 192.168.1.3 to eth0:0 (where eth0 is the primary interface address). If you look at the output of ifconfig, you'll see the distinct IP address for eth0 and another for eth0:0.

If you need to add another IP address, use the same command with an incremented alias number (i.e. eth0:1, eth0:2, and etc.). You may assign up to 256 IP aliases on a given NIC.

To make IP aliasing permanent (survive system reboots), you may configure IP aliasing by creating configuration file(s). On Red Hat, Mandrake and similar systems, you may create files in /etc/sysconfig/network-scripts/. In this directory, create a new file called ifcfg-eth0:0 that contains the following contents:

IPADDR="192.168.1.3"
NETMASK="255.255.255.0"

On systems that do not use those network scripts, just add the ifconfig command (shown above) directly in the startup script (i.e., /etc/rc.d/rc.local).

   

 
WEB HOSTING SHOWCASE