How to assign static ip in Ubuntu from terminal

To assign static ip in Ubuntu from terminal, follow this procedure:

# First open the interfaces file by using any editer of your choice, like below
$ sudo vi /etc/network/interfaces


# Now add the following lines in above file with your desired ip values
autho eth0                                // Here we are creating etho
iface eth0 inet static
address            // Here choose your ip address
gateway            // Here assign your gateway ip address
netmask            // Here assign your net mask address
broadcast            // And finally here assign the broadcast address.



# Save the file and restart the network

$ /etc/init.d/networking restart


That’s it, now will be having the static ip assigned with the terminal.


Leave a Reply