Generally, when you install any Operating System, DHCP will assign a dynamic IP address. But there are some cases where you are required to assign a static IP address such as if you are using your system as a Server or granting someone remote access to your System.
In all of those cases, you will need a static IP because things such as servers should not be changing their IP addresses frequently. So let’s start the process of setting up a static IP on Debian
Table of Contents
Setting up Static IP Address on Debian 11/10
We will show you two different methods, one is Terminal based and another is GUI based by which you can change your dynamic IP address to a static IP Address. We will start will the Terminal-based method.
Method 1 – Setting up Static IP Address Using Terminal in Debian 11
If you are a little familiar with Terminal, you can easily perform given tasks and for your ease of use, we have also included screenshots of each step.
Let’s available networks in the Debian system
We will use IP which is the main command and often used to show us what are the currently available Network interfaces in our system. We are also going to use the link command which is a subcommand used with IP to make changes in Network interfaces
This has shown us the active Network interface which is enpos3 and we will change enpos3 from dynamic to static IP.
Now, we will have to make some changes to our Network configuration file which is located at /etc/network/interfaces. We are using nano as a Text Editor because it is easy compared to vim, but you can use any preferred Text Editor. Use the following commands:
sudo nano /etc/network/interfaces
You will be asked to enter your password. Enter your password and you will be prompted to a completely new window. It is a nano text editor by which we are going to make changes to our file.
Now, we will have to enter our preferred choices related to which static address you want, your netmask, dns-nameserver. We have mentioned our preferred choice. You can tweak them according to your choice.
iface enp0s3 inet static
dns-nameservers 18.104.22.168 22.214.171.124
As you can see in the second line, we have mentioned that our Network Interface enp0s3 will be static. Insert these configurations at the end of our configuration. It will look like this:
To save the changes which we have made, press Ctrl + O. To quit from nano press Ctrl + X.
To make things work as our desired configuration, we are required to restart our Network Manager. Use the following commands to restart your Network Manager.
sudo systemctl restart NetworkManager.service
To verify whether the required changes have been made or not, use the following command:
As you can see, we have successfully configured the static IP address for our Network Interface enp0s3 at 192.168.2.2.
Method 2: Setting up Static IP Address Using GUI in Debian 11
If you do have a desktop environment instilled, you can use this method (In my case I’ve unofficial GNOME 40).
Open your App menu and search for settings. Click on the first result.
If you are using a standard version of GNOME, unlike me you will find your wireless network in the Networks menu. My wireless device is listed under WI-FI.
Click on the small gear button that is placed next to your Network’s name.
Now, click on IPv4. Then select the manual option.
Enter your required configuration in Address, Netmask, and Gateway. After that, click on Apply button.
Now, open the Details section. You will be able to see the changes we made recently.
Frequently asked questions related to IP Address
How do I find a static IP address in Linux?
There is no predefined command which shows you whether you have dynamic or static IP. But there is one way, you have to note down your current IP and then Restart your machine. If it changes its IP, then it is assigned by DHCP, and if not then it is static.
Is static IP safe?
A static IP address is considered more vulnerable than a dynamic because it doesn’t change. It makes it easy for hackers to track you and gain access by continuously attacking your network.
You may get higher speeds by setting up static IP on Debian and it is bundled with some risk too. But there are some use cases when you are required to use static IP, ignoring some vulnerabilities it has which you can handle by the Cyber security expert.