How to configure Static Local IP Address in Ubuntu

  • Post last modified:March 7, 2021
  • Reading time:2 mins read

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.

Step 1

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

Step 2:

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 4.4.4.4
  dns-nameservers 8.8.8.8

In 3rd line is the IP you want to fix for your system. Change it according to your requirement.

Step 3:

Finally restart your network daemon to save all changes.

$ systemctl restart network

Static IP for your local system has been configured successfully.

Conclusion

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.

Like what you read? Please share it with others.
  • 24
    Shares
guest
0 Comments
Inline Feedbacks
View all comments