Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks



Sunday, 29 September 2013

How To : Create an Alias for a Network Interface in Ubuntu/Linux Mint

ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux,

    The process in which multiple addresses are created on a single network interface, is known as "IP Aliasing". IP Aliasing will be very much useful when you need multiple IP addresses to set up multiple virtual sites on Apache making the use of only one network adapter. The most important advantage of IP Aliasing is that you do not need one hardware per IP Address, rather you can generate a pool of virtual network interfaces (i.e. Aliases) on a single device.

    In this article, we will learn how these aliases are created and how we can assign an IP address to each of them. This very very very simple.

    Here we go!

    Let us consider that we have an ethernet interface 'eth0' with an IP address 192.168.186.141 and we have to create an alias 'eth0:0' with an IP address 192.168.186.142 on eth0. To do this, just enter following command:

sudo ifconfig eth0:0 192.168.186.142
or

sudo /sbin/ifconfig eth0:0 192.168.186.142
To verify whether alias is enabled and running fine, just ping it as follows:

ping 192.168.186.142

Permanent Settings

When you make all the above changes and if the system is restarted, then all the changes made by you will be lost, as they are saved in volatile memory of your system. So as to make those changes permanent, you will have to add them to the network configuration file which is located at /etc/network/interfaces.

Use your favorite text editor to open the file and add the following configuration to it.

sudo gedit /etc/network/interfaces

auto eth0:0
iface eth0:0 inet static
name eth0 Alias
address 192.168.186.142
netmask 255.255.255.0
broadcast 192.168.186.255
network 192.168.186.0
Save the /etc/network/interfaces file and restart the networking service as follows:

sudo service networking restart
or

sudo /etc/init.d/networking restart
To observe whether your new interface has been added or not, run the following command:

ifconfig
Output:
ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux,

ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux, ip-aliasing-in-linux,

In the similar way, you may create some more aliases having names eth0:1, eth0:2 and so on up to eth0:254 assigning them with different IP addresses.

3 comments:

  1. Hey Mandar,

    Thanks for the How-To.

    I want to connect to each of the aliases ip using ssh remotely.
    I manage to connect only to the "original" ip and not the other ip's.

    Any thoughts ?

    Thanks again,

    James

    ReplyDelete