+370 5 205 5502 sales@monovm.com

In this article we are going to add the extra IP on one NIC (Network Interface Controller) in Ubuntu.

27

Dec, 18

A through Ubuntu IP tutorial

If you want to add an extra IP on one NIC (Network Interface Controller) in Ubuntu Linux VPS, you have two options. Either using a temporary IP or using a  permanent one.

  1. Adding temporary extra IP :
    1. Enter the Ubuntu terminal
    2. Enter this command to add the temporary extra IP

              ifconfig [nic]:0 [IP-Address] netmask [mask] up

               An example is shown below

               ifconfig eth0:0 192.168.1.2 netmask 255.255.255.0 up

        Note: This IP is valid until you reboot the system. 

  1. Adding Permanent extra IP: This IP won’t be deleted if you reboot the system.
      1. Enter the Ubuntu terminal
      2. Open the ‘/etc/network/interfaces’ file with one editor

                nano /etc/network/interfaces

      1. Enter these codes at the end of the file:   
    1.          auto [NIC]:[n]

            iface [NIC]:[n]

            inet staticaddress [ip add]

            gateway [gate way]

            netmask [net mask]

          4. For example:

                auto eth0:1

                iface eth0:1

                inet staticaddress 192.168.0.1

                gateway 192.168.0.254

                netmask 255.255.255.0

         To add more IPs just follow the above steps. Just change eth0:1 to eth0:2 and so on

 Congratulations now you know how to add extra IPs.

Sophia H

My name is Sophia H. My degree is MS in Information Technology Engineering. I have been working for 5 years on Java developing (j2ee), Computer Networking (Optical Networks), Virtualization and Hosting.