Ubuntu Linux: Creating ethernet alias for eth0 network device

Q. I am using Ubuntu Linux and I would like to know how to create alias for eth0 so that I can have multiple IP address?

A. To create alias for eth0 use ifconfig command. It is use to configure a network interface and aliases.

Assuming that your eth0 IP is 192.168.1.10 and you would like to create an alias eth0:0 with IP 192.168.1.11. Type the following command:

sudo ifconfig eth0:0 192.168.1.11 up

OR

sudo /sbin/ifconfig eth0:0 192.168.1.11 up

Verify that alias is up and running using following two command(s):

/sbin/ifconfig
ping 192.168.1.11
ping your-getway-ip

Permanent configuration

Your ethernet configuration is located in a file called /etc/network/interfaces. If you reboot system you will lost your alias. To make it permanent you need to add it network configuration file:

gksudo gedit /etc/network/interfaces

OR

sudo vi /etc/network/interfaces

Append the following configuration:

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0

Save the file and restart system or restart the network:

sudo /etc/init.d/networking restart

Please note that you can also use graphical tools located at System > Administration > Networking menu. Or use the following GUI tool to setup aliases, hostname, dns settings etc:

sudo network-admin

If you want more network aliases, use eth0:1, eth0:2, eth0:N (max upto 254).

See also:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 12 comments… read them below or add one }

1 kotnik 06.18.06 at 12:15 am

/sbin/infconfig

There’s no such command. Fix the typo ;)

2 LinuxTitli 06.18.06 at 11:26 am

kotnik,

Err…

thanks for heads up :)

3 Cloudless 08.04.06 at 8:20 am

Thank you so much for this guide! It is easy to understand.

4 Tamil 12.28.06 at 11:08 am

simple and good guide. Thank you.

5 Alex 01.28.07 at 6:23 am

What if you don’t use a permanent ip address and
rely on DHCP to assign the IP address?

Is this correct?
sudo ifconfig eth0 up

Do I need to setup dhcp?

6 jusdur 08.08.07 at 3:12 am

what does mean this line:
name Ethernet alias LAN card

i look into man interfaces, but can’t found about name syntax

thx

7 Zulqarnain 11.27.07 at 7:53 am

i solve my problem of multi addresses.

8 Jayesh Sharma 07.16.08 at 10:50 am

Hi All,
This is a very good site to linux learner.But how can i post my query to get resolution.

9 vivek 07.16.08 at 11:14 am

Jayesh,

Use our Linux support forum

10 Alex 10.03.08 at 12:36 pm

When creating an alias, must it be in the same subnetwork?
To explain better, if my ip address id 1.1.1.1/255.255.255.0, the alias must be 1.1.1.x or can it be 2.x.x.x?

thanks

11 Manu Ignatius 11.25.08 at 2:08 am

This link might be somewhat useful for aliasing an interface using programming.
Link

12 Gaurav Pruthi 01.22.09 at 5:38 am

Why we can’t use more than 254 aliases on a NIC?
If i am using 2 NICs in my box, will the max. limit be 508?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , , , , , , , ,

Previous post: Finding out who is logged on to a Solaris system

Next post: Linux – lspci command to list and find out more information about all PCI devices