How to set up static IP address on Debian Linux 10/11

I have Debian 10 Linux cloud server, and it is configured to get IP addresses via DHCP. How do I convert DHCP address to static IP address settings?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Debian Linux
Est. reading time 5m
By default, the DHCP server will provide IP information in your network. Your DHCP client on Debian Linux will obtain an IP address, subnet, default route, DNS server/resolvers IP address, and other information configured on the DHCP server. Let us see how to add, configure and set up a static IP address on Debian Linux version 9/10/11.

How to static IP address on Debian Linux

The procedure is as follows to set up and configure a static IP information:

  1. Open the terminal application.
  2. Log in to remote or server using ssh command.
  3. Backup /etc/network/interfaces file running sudo cp /etc/network/interfaces /root/
  4. Edit the /etc/network/interfaces
  5. Configure static IP address for enp0s5 Ethernet interface: address
  6. Add subnet mask: netmask
  7. Set up default gateway IP: gateway
  8. Finally add DNS resolver IP: dns-nameservers

Let us see all commands and examples in details.

Finding your network interfaces name on Debian Linux

Use the ip command as follows to show/display available Ethernet network interfaces:
ip -c link show
Also, we can try the following Linux command to show a list of network cards:
sudo lshw -class network -short
lspci | egrep -i --color 'network|ethernet|wireless|wi-fi'
ip -br -c link show

Note down the Debian Linux interface name and type the following ip command to see the current IP address assinged to that network interface:
ip -c addr show enp0s5

How to setup a Static IP address on Debian Linux

Finding NIC name and IP assigned by the DHCP server on Debian Linux

Configuring Static IP on Debian 10 or 11

The /etc/network/interfaces[/file] contains network interface configuration information for Debian Linux. Hence, edit the file:
sudo vim /etc/network/interfaces
## OR ##
sudo nano /etc/network/interfaces

Look for the primary network interface enp0s5:

allow-hotplug enp0s5
iface enp0s5 inet dhcp

Remove dhcp and allow-hotplug lines. Append the following configuration to set up/add new static IP on Debian Linux 10/11. Here is my sample config file:

# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s5
iface enp0s5  inet static
 dns-domain sweet.home

Save and close the file when using vim/vi text editor.

Restart networking service on Debian Linux to switch from DHCP to static IP config

Warning: Do not run the following over ssh based session as you will disconnect.

Use the systemctl command as follows:
sudo systemctl restart networking.service
Make sure service restarted without any errors. Hence, type the following command:
sudo systemctl status networking.service
Sample session:

 networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2021-01-27 23:10:00 IST; 1min 38s ago
     Docs: man:interfaces(5)
  Process: 1104 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
 Main PID: 1104 (code=exited, status=0/SUCCESS)

See your new IP address assigned on Debian Linux

Again type the following ip command:
ip -c addr show
ip -c addr show enp0s5

How to configure Static IP on Debian 10 or 11
When you change your IP address, you need to restart other services such as Nginx, SSH, etc. It all depends upon how you configured those services with IP binding. Make sure you adjust the firewall settings too.


You learned how to convert the existing DHCP to static IP address settings on Debian Linux version 9/10/11. See Debian Linux man page online or type the following command:
man interfaces

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Clownfeuer Jan 27, 2021 @ 18:42

    auto not audo

    • 🐧 Vivek Gite Jan 27, 2021 @ 19:12

      Opps. Fixed it. Thanks kind stranger.

      • Mhe Jan 28, 2021 @ 10:15

        default gateway is not a good example in your list. This would not reachable, right?

        • 🐧 Vivek Gite Jan 28, 2021 @ 12:05

          Oh no. My tired eyes. Fixed it. Thank you very much!

  • Slinus02 Jan 28, 2021 @ 12:35

    While I respect the existence of the IP Commands, I’d rather use ifconfig because it’s so much simpler and I really don’t understand why you have to Install net-tools after the fact.

  • Robert Derochette Jan 29, 2021 @ 10:47

    To make sure you don’t choose a static IP that is already assigned, scan your network first using nmap. For example, if your network is then do

    nmap -sP 192.168.1.*

    This will list all the machines connected to the network. If you perform the command as root you will often get enough information to know which address corresponds to each machine.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum