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

Assigning-static-ip-with-terminal

# 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 192.168.1.45            // Here choose your ip address
gateway 192.168.1.1            // Here assign your gateway ip address
netmask 255.255.255.0            // Here assign your net mask address
broadcast 192.168.1.255            // And finally here assign the broadcast address.

Assigning-static-ip-with-terminal2

 

# Save the file and restart the network

$ /etc/init.d/networking restart

Assigning-static-ip-with-terminal3

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

 

Leave a Reply