In Linux, if you were working on networking, you may be came to a point when you need to assign static IP to your system over the local network.
There may be any reason. If you want to communicate with a PC on the network, then whenever your system restarts, local IP changes based on the subnet mask. To avoid this, you need to fix your preferred local IP in the network configuration.
Table of Contents
Before going further, open your terminal using
CTRL + ALT + T depending upon the type of distro you use or search terminal in the Activity search bar.
To setup Static Local IP in Debian based distribution like Ubuntu or PopOS. Open the below file in your preferred Text Editor. In my case, I am using nano.
$ nano /etc/network/interfaces
When the file opens, you will get a predefined template that you need to configure according to your requirement.
auto eth0 iface eth0 inet dhcp
Copy-paste below configuration information in your interfaces file.
auto eth0 iface eth0 inet static address 192.168.0.105 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 18.104.22.168 dns-nameservers 22.214.171.124
In 3rd line is the IP you want to fix for your system. Change it according to your requirement.
Finally restart your network daemon to save all changes.
$ systemctl restart network
Static IP for your local system has been configured successfully.
This method is effective when there are multiple systems in your network and you the one who first booted. If another system booted first and your defined IP is assigned to them, this cannot work for you.
For such a case, you need to configure local IP for your system on the router. If you still getting confused, feel free to ask in the comment section.
Innovative tech mind with 10 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.