Ubuntu Linux: Creating ethernet alias for eth0 network device

by LinuxTitli on June 17, 2006 · 20 comments

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:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 20 comments… read them below or add one }

1 kotnik June 18, 2006

/sbin/infconfig

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

Reply

2 LinuxTitli June 18, 2006

kotnik,

Err…

thanks for heads up :)

Reply

3 Cloudless August 4, 2006

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

Reply

4 Tamil December 28, 2006

simple and good guide. Thank you.

Reply

5 Alex January 28, 2007

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?

Reply

6 jusdur August 8, 2007

what does mean this line:
name Ethernet alias LAN card

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

thx

Reply

7 Zulqarnain November 27, 2007

i solve my problem of multi addresses.

Reply

8 Jayesh Sharma July 16, 2008

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

Reply

9 vivek July 16, 2008
10 Alex October 3, 2008

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

Reply

11 Manu Ignatius November 25, 2008

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

Reply

12 Gaurav Pruthi January 22, 2009

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?

Reply

13 Download Free Photos August 31, 2009

Hello,

Can I manually add IP to /etc/network/interfaces ?
Can someone post an example of multiple IP addresses on one NIC ?

thanks

Reply

14 Ross Sutherland September 1, 2009

Hell there. I am a new Linux user, more specifically Ubuntu. I was confused what was meant be the following line – “name Ethernet alias LAN card”. Is this the physical device name or just eth0?

Any help with this would be great thanks.

Reply

15 Ross Cooney June 14, 2010

Thanks for the helpful tip.

Reply

16 Alexis Wilke November 20, 2010

That is exactly what I have in my file… including the auto eth0:0. However, it looks like the auto is not that automatic on a reboot. Have you had problems on a reboot? Wondering because I’ve seen many people running in the problem of the 2nd IP disappearing after the machine is restarted.

Thank you, Alexis

Reply

17 Anonymous April 21, 2011

I have the same problem as Alexis Wike, Did anyone come up with a solution for this. After reboot the eth0:0 does not comeup. The auto eth0:0 line is there in the file but it seems that it does nothing. Thanks

Reply

18 Mitter Singh Thakur September 16, 2011

Hi all,

Thanks!

Can you please tell me why there is limit to create an alias for NIC?

How many IP’s we can assign to a single NIC any Why???

regards,
Mitter Singh Thakur
System Admin
+91-7737603000 | +91-8890152367 | mitter1989@gmail.com

Reply

19 Alexis Wilke September 20, 2011

Mitter,

Yes. The limit is something like 254. It one byte. 0 and 255 cannot be used or something like that.

Alexis

Reply

20 Michael December 18, 2011

The reason you may be having problems w/ AUTO on an alias is that you are not allowed to use anything other than the default subnet for the ip range in question.

(Example: 10.x.x.x uses a default subnet of 255.0.0.0) If you try to assign any other subnet mask to the aliased ip, it won’t let you, and will take down the interface instantly. (Also true if you use ifconfig to assign the netmask).

Kind of ruins the point needing things like a server w/ several 10.x.x subnets, and forces one to use 192.168 addresses for 255.255.255.0.

Which would be fine if one didn’t already have a complex subnetted 10.x.x.x set of ranges in place because 192.168 doesn’t have enough subnets.

Really annoying that.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">




Previous post:

Next post: