Linux and Windows IT Support  

We make IT Support easy!

Windows, Apple and Linux IT support and services.

Login or Register  

If you wish to contribute an article, please login or register.

Multiple IP adresses for 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 and you would like to create an alias eth0:0 with IP Type the following command:

sudo ifconfig eth0:0 up


sudo /sbin/ifconfig eth0:0 up

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

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:

sudo vi /etc/network/interfaces


sudo vi /etc/network/interfaces

Append the following configuration:

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card

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).

Comments (9)
Two public IPs to help out firewall?
9 Thursday, 07 March 2013 07:00
Hi All,
Just a question - let's say I'd like to use two public IPs. One for the host machine and the other for VMs in the DMZ. Therefore, all I need to do is create alias eth0.0, set additional public IP to it and postroute all the traffic to e.g. network? Will it work? Is it better solution than creating vmbr0?
My idea is to hide the first IP that I'm using for the host machine and "publicly" use only the second one with port forwarding on.
Thanks a bundle!
8 Tuesday, 07 February 2012 06:31
Works on Ubuntu 11.10 but is easier with gedit instead of vi :D
permanent setting on Ubuntu 11.10
7 Monday, 23 January 2012 04:13
"Now I want to make it permanent but I can't figure out what to add to my /etc/network/interfaces file. "
Same here.
Seems to be broken on Ubuntu 11.10
6 Wednesday, 11 January 2012 13:27

I'm new to linux.
I'm trying to access 2 networks from the same pc with 1 NIC.

Main network:
Gateway: 192.0168.15.254

Secondary network:

I tried your example:

sudo ifconfig eth0:0 up

and it worked fine.

Now I want to make it permanent but I can't figure out what to add to my /etc/network/interfaces file.

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card

Is this correct?
It is not working for me.

Thanks in advance.

re: how to define route
5 Monday, 28 November 2011 11:24
@Umar: I'm not sure how you would do that with DHCP, you'll need a way to get an IP address in your config. You can try using variables: EXTIP, EXTMASK, etc. I assume that eth0 is your EXTERNAL card and eth1 is your INTERNAL card:

In /etc/iproute2/rt_tables, add those two at the bottom:

# reserved values
255 local
254 main
253 default
0 unspec
# local
#1 inr.ruhep
1 first
2 second

then, in /etc/rc.local add the following (before exit 0):

EXTIP="`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
EXTMASK="`/sbin/ifconfig eth0 | grep 'mask' | awk '{print $4}' | sed -e 's/.*://'`"
EXTNET="`/sbin/route -n | grep 'eth0' | awk '{print $1}' | sed -e 's/\0\.\0\.0\.0//'`"
EXTGW="`/sbin/route -n | grep 'eth0' | awk '{print $2}' | sed -e 's/\0\.\0\.0\.0//'`"

ip route add $EXTNET/$EXTMASK dev eth0 src $EXTIP table first
ip route add default via $EXTGW table first

ip route add dev eth1 src table second
ip route add default via table second

ip rule add from $EXTIP table first
ip rule add from table second

It should work, in theory. (I haven't tested it with variables, I use static IPs in all my setups). If that doesn't work, you'll have to manually replace the variables with IPs. This will give you 2 routes, with access to both external and internal networks.
how to define route
4 Monday, 28 November 2011 10:40
no both are different... i have two Ethernet cards one has IP address (local) and the other one is without IP(internet)
but my it goes directly to internet... in windows i defined routes so i was able to use both networks at one time.
hope you understand my problem
details for my network is given below:
IP address:
Subnet MAsk:
Gateway :
DNS Server :

hope you understand my problem
re: how to define route
3 Monday, 28 November 2011 10:32
@Umar: you'll have to do source routing in order to achieve this. What exactly are you trying to do? Are you accessing the same subnet or 2 different ones?
how to define route
2 Monday, 28 November 2011 10:28
i have two Ethernet card in my pc. i am using Ubuntu 11.10 and want to define network route. can someone please help me in this.... thanks
1 Monday, 14 November 2011 19:20
Tested on Ubuntu 10.04.

Add your comment

Your name:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
Copyright © 1999 - 2017 Virtual Helpme | Trusted IT Services | Original Template: Allrounder