How to assign static ip in Ubuntu from terminal

In this tutorial, we will be learning how to assign static IP in Linux from the terminal. We will be using the Ubuntu operating system to demonstrate this in this tutorial.

How to assign static IP

First, open the interfaces file by using any editor of your choice, we are using vi command here.

sudo vi /etc/network/interfaces
assign static ip
assign static ip

Now add the following lines in above file with your desired ip values

autho eth0
iface eth0 inet static
  • address is your IP address
  • gateway is your gateway IP address
  • netmask is your netmask address
  • broadcast is the broadcast address.
edit interfaces in linux
edit interfaces in linux

Now save the file and restart the network with the following command.

/etc/init.d/networking restart
restart network in linux
restart network in linux

That’s it, now we have the static ip assigned.

Add a Comment

Your email address will not be published. Required fields are marked *