How to Add an IP Address in Ubuntu using Command?

Sometimes you may require to add the IP Address manually in the Ubuntu network interface, which you can do by following these steps –  

1. Log in to the Ubuntu server via SSH.

2. Execute the following command – 

# nano /etc/network/interfaces

3. Enter the interface alias eth0:0 as mentioned below –  

#secondary ip address
auto eth0:0
iface eth0:0 inet static
address 1*3.2*8.149.***
netmask 255.255.255.***



If you already have an interface alias eth0:0, then you can add eth0:1 or eth0:2 for an additional IP Address. 

4. The command given below will up the added interface alias within the network – 

# ifconfig eth0:0 1*3.2*8.149.*** up

5. Restart the network service

# /etc/init.d/networking restart

6. Check the newly added IP Address with the below command – 

# ifconfig

That's it.
You have successfully added the IP Address on the Ubuntu server.


Was this answer helpful?

« Back