English
+(370) 5 205 5502 sales@monovm.com

At MonoVM we provide you with the underlying facts, assumptions and rules which a computer system has.

27

Dec, 18

How to add an extra IP to Ubuntu OS?

If you want to add an extra IP on one NIC (Network Interface Controller) in Ubuntu, 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 above steps. Just change eth0:1 to eth0:2 and so on

 Congratulations now you know how to add extra IP's.

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.