Hello Debian users, welcome to Debian Tutorial for Beginners. In this article, I am going to show you how to change the static IP address on Debian 11. In some cases, we may need to change from automatic to static IP address. If this is your case, so you came to the right place. This article is also applicable to Debian’s 10 users as well.
Steps to Set Up Static IP Address on Debian 11 Server
This task requires a little knowledge of the Terminal command in Linux. But don’t worry, I will try to explain it every single step.
Step 1. Back up the network interfaces configuration file.
Open the Terminal application on Debian 11. In case you connect to Debian 11 remotely, you can use SSH applications such as Putty or Termius. Because we are going to edit the network configuration file, it would be safe to make a back up of it.
cp interfaces interfaces_backup
The command above will make a backup of the interfaces file into interfaces_backup.
Step 2. Edit the configuration file
Now we are going to edit the interfaces config file. I use nano text editor.
This is the default content of the configuration file
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback
The default config will use the automatic (DHCP) IP address. To set up the static IP address, we need to add these lines to the interfaces config file.
# The primary network interface auto enp2s1 iface enp2s1 inet static address 192.168.128.12 netmask 255.255.255.0 gateway 192.168.128.1 dns-nameservers 192.168.128.1
enp2s1 is the network interface name of mine. To find yours, please use this command:
ip -c link show
Make a note of your network interface name and then use it in the configuration file. Once finished editing the file, close it and restart the networking service.
systemctl restart networking
Now check the IP address and make sure it is working properly. Try to use it for internet browsing etc.