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
Now add the following lines in above file with your desired ip values
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.
Now save the file and restart the network with the following command.
That’s it, now we have the static ip assigned.