In this tutorial we will learn simple steps to configure the static ip address in Ubuntu by using command line.
It is always be a good practice to work on Linux or Unix system using command line.As a system admin we always prefer to work by using command line.
Follow the given below steps to configure static ip address through command line in Ubuntu
Step 1: Login into your system and become a superuser or root
sudo su - or su -
Step 2: Now edit the file /etc/network/interfaces. Before this first of all you have to check what is the ethernet device name which is available in system and on which we will configure the static ip address.
First of all run the below command and find the ethernet device name,here for eg, we are using eth0
Now edit the /etc/network/interfaces file using your favorite file editor and paste the given below content as per your information. (Here I am using the vi editor)
Replace the given value
aa.bb.cc.dd replace with the ip address assigned for the system
yyy.yyy.yyy.yyy replace with Netmask of IP Address
pp.qq.rr.ss replace with Gateway IP Address
vi /etc/network/interfaces auto eth0 iface eth0 inet static address aa.bb.cc.dd netmask yyy.yyy.yyy.yyy gateway pp.qq.rr.ss
auto eth0 iface eth0 inet static address 192.168.122.101 netmask 255.255.255.0 gateway 192.168.122.101
Step 3: Now restart the network service
Step 4: To change the Nameserver settings. Edit the resolv.conf file. In below example I am using Google Nameserver IP Address. You can replace the nameserver information as per your network requirement.
vi /etc/resolv.conf nameserver 18.104.22.168 nameserver 22.214.171.124