Create Virtual Network Adapters in Ubuntu 12.04 (Precise Pangolin)

This tutorial is for users who want to experiment a bit with Ubuntu Linux. It not for everyone, especially those with machines that are used in production.

If you know a thing or two about networking and IP networks, then you know that in most cases, each network card will only be assigned one IP address. It’s a one to one thing and that’s what we’re used to.

The thing with one network card  and one IP address is, you can only host or run in single network service/port on a machine with one nic card and IP address. For example, if you wish to run a web server, on port 80, only one web server will listen on that one IP address and that port #. That’s how it’s designed to work.

So, instead of the one-to-one relation with network cards and IP addresses, you can create virtual network cards that can be assigned individual IP addresses. So, a single physical network card can host unlimited sub-nic cards or virtual nic. Each can then be assigned their own IP addresses with assigned ports.

Enhance your coding experience with this split keyboard that offers up to 9" of separation.

This brief tutorial is going to show you how to do that in Ubuntu. It’s a great way to run and test multiple network services with single port # on a single computer with one network card.

To get started, run the commands to open the network interfaces file.

sudo gedit /etc/network/interfaces


Then add as many virtual network cards as you want by following the steps in the picture below. By default, Linux machine assigned eth0 name to the first network card. So if your machine has one network card, it will be named eth0.

To add virtual network cards, create more static cards and name them eth0:1, eth0:2, eth0:3, etc. (eth0 followed by colon and a number).




Also, for each network card you create, make sure each network is in a separate subnet.. this is  networking 101.

When you’re done, save the file and reset the networking service by running the commands below.

sudo service networking restart


That’s it!





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Invest in some screen real estate with a new big screen, backlit monitor availabe in five different sizes and price points.

5 thoughts on “Create Virtual Network Adapters in Ubuntu 12.04 (Precise Pangolin)”

  1. I was able to create a virtual ETH0:1 using this method, but now I have no internet on ETH0. I cannot ping and my javascript program cannot talk to my MySQL server over the internet. It seems as though it is trying to route all internet traffic through the “LOCAL ONLY” virtual adapter. Any ideas how I can fix this?


  2. This is great information. I need help to understand , how do I add separate subnet for each Network.

    My netmask is
    and gateway is ( this is Netgear firellwall router IP address)

    If I use this as gateway for First card then what will be the gatewayy for another card.

    Please help me here, I am not a network person.

  3. I am unable to change the subnet number without breaking that virtual network. I don’t receive any errors, and my server seems to use the virtual network, but trying to access the server from the IP with a different subnet does not work. Help?

Leave a Reply

Your email address will not be published. Required fields are marked *