Debian

How to set up a static IP address on Debian 11

When you install a new operating system on your computer, the DHCP server assigns you a dynamic IP address. However, you may need to set up a static IP address on your machine in various situations, such as when you are hosting a web server, or any service requires an IP address rather than a domain name, or in a case where you are about to grant someone remote access to your system. Whatever the reason is, you should know how to set up a static IP address on your system.

In this post, you will learn how to set up static IP on Debian 11 using two different methods. So, let’s start!

Method 1: Set up a static IP address on Debian 11 using terminal

As a Debian user, you can easily set up a static IP by using your terminal. To do so, firstly, you have to select an active network interface on your system.

How to check available network interfaces on Debian 11

You can utilize the “ip” command to get the details about your system’s currently available network interfaces. The “ip” is an abbreviation for “Internet Protocol”. The “ip” command is a utility used by network and system administrators in Linux-based systems to configure network interfaces. In the “ip” command, “link” is the sub-command added to view and modify the network interface. Write out the below-given command in your Debian 11 terminal for viewing the currently available network interfaces:

$ ip link

From the output, we will note down the name of our active network interface, which is “enpos3”. As “enpos3” is the network interface for which we will set up a static IP:

How to set up a static IP address on Debian 11

Now, open the configuration file of the network interfaces “/etc/network/interfaces” in the nano editor:

$ sudo nano /etc/network/interfaces

With the default settings, your network interfaces configuration file will look like this:

In the “/etc/network/interfaces” file, add the following details about your network interface, such as its static IP address, which you want to set up, netmask, gateway, dns-nameservers:

auto enp0s3
iface enp0s3 inet static
address 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.2
dns-nameservers 8.8.4.4 8.8.8.8

Here, the first two lines declare that we are setting a static IP address for the “enpos3” network interface:

To save the changes you have made in the network interface configuration file, press “CTRL+O”:

How to restart the networking service on Debian 11

After configuring the static IP address for the “enpos3” network interface, now we will restart the networking service using the systemctl command:

$ sudo systemctl restart NetworkManager.service

You can verify if your Debian system has configured the static IP for your selected network interface:

$ ip a

From the output, you can see that we have successfully configured static IP address our “enpos3” network interface to “192.168.2.2”:

Method 2: Set up a static IP address on Debian 11 using GUI

Debian 11 also provides you the facility to set the static IP address of your active network interface using its GUI. If you want to utilize the Debian GUI method for configuring the static IP address, then open your system settings by searching “settings” in the Application’s bar:

From the different categories present in the left side menu, select “Network”. Open settings of your active network connection by clicking on the gear icon:

In the opened network settings window, click on the “IPv4” tab. Select the “Manual” IPv4 method for your network:

After that, add your static IP address, Netmask, Gateway, DNS for your network, and then click on the “Apply” button:

Now, open the “Details” tab. Here, you will verify the added details for your network, such as its IP address:

That’s how you set up the static IP address for your network interface on Debian 11 using its GUI.

Conclusion

Debian 11 provides you the option to set up a static IP address for your system, whether you want to do it for hosting your web server or granting remote access to anyone. DHCP automatically enables a dynamic server when you install a new operating system. However, you can configure your IP address using Debian terminal and GUI. In this post, you have learned how to set up a static IP address on your Debian 11 using two different methods.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.