Adding Sub-Interfaces and IP addresses on Ubuntu 14.04LTS

If you have been given your own private subnet (we still say /29) from your hosting provider and have 5 websites that need their own dedicated IP address. You will be able to add sub-interfaces onto a single NIC (network interface card), and assign each sub-interface with its own dedicated IP address from the subnet.

You will need to be either root or have an user with sudo privileges

1. Edit the interfaces file within the network folder

sudo nano /etc/network/interfaces

2. Add the additional IP addresses under eth0

# The primary network interface - 14 are usable IP addresses
auto eth0
iface eth0 inet static

# The Rest of the IP addresses in the /29
auto eth0:1
iface eth0:1 inet static

auto eth0:2
iface eth0:2 inet static

3. Restart the network daemon

sudo /etc/init.d/networking restart

4. Enable the new sub-interface

sudo ifup eth0:1

This will create a NIC alias and therefore allow you add additional IP addresses. This can be done for up to 254 IP addresses

The following two tabs change content below.

Keeran Marquis

Network Engineer
Keeran Marquis is a Network Engineer. His main goal is to learn everything within the Networking field, pick up a little bit of scripting, be a poor man sysadmin and share whatever he knows! All Posts are his own views, opinions and experiences, no guarantees they will work for you but point you in the right direction 🙂
Share this:

2 thoughts on “Adding Sub-Interfaces and IP addresses on Ubuntu 14.04LTS”


    Hey Kareen,

    If we do the same with IPv6, ifconfig show them under ens3 and not under ens3:1 or ens3:2. How to make IPv6 show under subinterfaces? (ubuntu-xenial)

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.