debian 12 bookworm Debian is the latest stable version of the system which was introduced on July 13, 2023. Like other Linux operating systems, Debian 12 gets an IP address when you connect the system to the Internet. However, by default, the IP address on Debian systems is dynamic and changes every time you go online. This can be annoying, especially for servers, games, or devices you control remotely. There is a trick to solve this problem static ip address Which will provide you with a reliable IP address, easy access to machines and remote control of devices from anywhere.
In this guide, you will find:
you can set static ip address From Debian 12:
you can set static ip address From terminal on Debian 12:
By default, Debian 12 includes a interface file In the network directory that you can use to configure your network. You can open this file and add your network details to change your network settings on your system.
To set static ip address From terminal on Debian 12 interface fileYou can use the following steps:
Step 1: Check whether the current IP address is static or dynamic
Before proceeding with the installation static ip address On Debian 12, you should check whether the current IP address of your system is static or dynamic, for this, use:
presence of dhcp The output of the above command ensures that the IP address of the system is dynamic.
Step 2: Make a backup of the interface file
It is better to make a backup of your network interface file through the below command as it will help you to revert the changes to default in case of error:
sudo clamshell ,etc,network,interface ,etc,network,interface.bak
Step 3: Install nmap on Debian 12
you can also install nmap On your Debian system that will help you get the list of IP addresses that you can use on your system. This is useful for beginners who are not sure which IP address they have to use.
you can install nmap On Debian 12 by the following command:
Step 4: Check IP Address List on Debian 12
Now to check the list of IP addresses on Debian 12, you can use nmap The command is followed by your network subnet 192.168.18.* in my case:
From the above list, you can choose any IP address as your static IP Address on Debian.
Step 5: Add network interface details
Now open the network interface file on Debian using the following command:
sudo nano ,etc,Network interface
Add the following lines, changing and keeping the IP address and default gateway as per your choice netmask And dns-nameserver Same:
iface enp0s3 inet stable
Address 192.168.18.111 # Enter your desired static IP address
netmask 255.255.255.0 # subnet mask
Gateway 192.168.18.111 # default gateway
dns-nameservers 220.127.116.11 18.104.22.168 # dns server
Then save this file using CTRL+XAdd Y and press enter,
Comment: We keep the default gateway same as IP address because our device is directly connected to another network without router and NAT device. You can change this to any value, but the first three subnets must remain the same. Also, if you have different IP address, you should set different netmask for each IP address so that they can be able to communicate.
You can also check your device name using:
Step 6: Restart Network Manager Service on Debian 12
After adding network settings, restart Network Manager Service On Debian 12 using the following command:
sudo systemctl restart NetworkManager.service
Step 7: Confirm that the current IP address is static
After reloading the changes, you can confirm whether the current specified IP address is static on Debian or not, this can be done with the following command:
Step 8: Check Internet Connectivity on Debian
To check if the internet is available on your device after the changes, you can use Humming Permission:
How to Set Static IP Address on Debian 12 from Terminal via NMCLI Command Line Utility
nmcli There is a Network Manager command line utility that comes pre-installed on Linux systems, including Debian 12. You can use this utility and set static ip address On your Debian system using the following steps:
Step 1: Check the device
before using nmcli order to install static ip address On Debian 12, you should use the command below to check the device name on your system:
Step 2: Create a Static Connection on Debian 12
Now, you can use the following command with the connection name and device to create a stable connection on Debian 12:
sudo NMCLI CON AD Type ethernet con-name 'static IP' ifname enp0s3 ipv4.method manual ipv4.address 192.168.18.22,24 w4 192.168.18.22
Comment: Don't forget to change the device name enp0s3, ip address And default gateway Because they may be different in your case.
Step 3: Add DNS IP to Static IP Connection
You should also add the DNS IP to your static IP Connection on Debian 12. This allows the device to resolve the domain name and connect to the Internet, this can be done with the following command:
sudo nmcli con mod static-ip ipv4.dns 22.214.171.124,126.96.36.199
Step 4: Activate Static IP Connection
after making static IP connection, use the following command to activate it on Debian:
sudo nmcli con up Identification 'static IP'
Step 5: Confirm that the current IP address is static
You can then use the following command to confirm the IP set on Debian nmcli The method is stable, it can be done using:
Comment: Don't forget to use the ping command to check internet connectivity on Debian:
How to remove connection from terminal on Debian 12 via nmcli command line utility
If you have configured your static IP In case of wrong connection, you can easily remove the connection nmcli order with connection name,
sudo remove nmcli connection Identification connection name
You can also open network settings from the GUI on Debian 12 set static ip addressThis can be done using the following steps:
Step 1: Open Settings on Debian 12
First, open Adjustment On Debian by selecting ethernet icon and click Adjustment Icon:
Comment: you can also open Adjustment On Debian 12 from the application search menu.
Step 2: Open Network Settings on Debian 12
click on Adjustment icon for wired network:
Step 3: Enable manual settings
Now, go to IPv4 tab and enable manual settings by checking box manual Option:
Step 4: Set Static IP Address on Debian
Now you can fill the box as per your choice, like adding static ip address In the Address box, enter the netmask, gateway, and default DNS. Once done, select apply Buttons to make changes to network configuration:
Step 5: Reload the Network
You should reload the network using the toggle button. To do this, first move it to the left to disable the connection and then move it to the right to re-enable it:
Step 6: Verify Connection
You can verify if the IP address has been successfully changed on Debian by going to Network Settings again:
Comment: Then, don't forget to use the ping command to check Internet connectivity:
You can remove the connection at any time using delete connection profile button.
to set a static ip address On Debian 12 there is a useful function that can be done from the terminal or the GUI. If you are using a terminal, you can set a static ip address From the interface file on Debian or by using nmcli Command line utility. From the GUI, you can set a static ip address By system settings in the network section. The complete step-by-step guide for both methods (Terminal and GUI) is discussed in the above sections of this guide. Performing these methods will help you set a permanent IP address for your Debian system.