How to Set Static IP Address on Debian 11 (Bullseye)

In this guide, we will demonstrate how to set static ip address on Debian 11 (Bullseye).

When we install Debian Linux on our system then during the installation it tries to get DHCP ip address from modem (or dhcp server) if available. But it is always to recommended to have a static IP address on your system. The main benefit of Static IP address is that it will be persistent across the reboot.

In Debian 11, we can set the static ip address either via GUI (Graphical User Interface) or via command line (cli).

Set Static IP Address via GUI

Login to your Debian Desktop environment, From Settings –> Choose Network

Network-Settings-Debian11

Click on Wired Settings and then we will get the following window,

Details-Tab-Network-Settings-Debian-Linux

Note: To disable IPv6, go to IPv6 tab and choose ‘Disable’ option

Click on IPv4 Tab

Automatic-DHCP-Network-Debian-Linux

Above window shows that Automatic DHCP is configured, so to configure Static IP choose Manual and then specify the IP details like IP address, netmask, gateway and dns server IP.

Note: To Specify the dns server IP first disable the automatic dns IP by toggling it.

Set-Static-IPv4-GUI-Debian11

Click on Apply to save the changes.

Now, disable and enable the interface by toggling it so that new IP address is assigned to the Interface.

Disable-Enable-Interface-Toggle-GUI-Debian11

Now again click on wired settings to verify whether the new static ip address is assigned or not.

New-Static-IPv4-Debian11

Perfect, above confirms that new static IP address is configured successfully. Now let’s see the alternate way to configure IP address in Debian Linux.

Set Static IP Address via Command Line

Open the terminal and identify the interface on which we will configure static IP address. Run below ip command,

$ ip add show

IP-Command-Interface-Name-debian

Now run nmcli command to get connection name,

$ nmcli connection

Once we get the connection name, run below nmcli command to assign static ipv4 address,

Syntax:

$ nmcli con mod  ‘connection-name’ ipv4.address  <IP-Address>

$ nmcli con mod 'eth0' ipv4.address 192.168.1.151/24

Set the gateway by running below

$ nmcli con mod 'eth0' ipv4.gateway 192.168.1.1

Change Configuration from DHCP to Manual , so that IP will be static and persistent, run

$ nmcli con mod 'eth0' ipv4.method manual

Set the DNS server IP by running below command,

$ nmcli con mod 'eth0' ipv4.dns '8.8.8.8'

Disable and enable the connection so that above changes come into the effect.

$ nmcli connection down eth0
$ nmcli connection up eth0

Now Run IP Command to check IP address,

$ ip add show eth0

Output of above commands would look like below:

Configure-Static-IP-with-nmcli-command-Debian11

Perfect, above output confirms that static IP address has been configured successfully on eth0 interface.

Set Static IP Address on Minimal Installed Debian 11

Whenever we install minimal Debian 11 then we will have only the CLI console and don’t have any nmcli utility. So, to configure static ip address we will edit the file ‘/etc/network/interfaces’.

Following is the default content in the file,

$ cat /etc/network/interfaces

Default-Interface-File-Debian

Edit the file and set the static IP address as shown below,

$ sudo vi /etc/network/interfaces

Delete the line ‘allow-htplug enp0s3’ and change dhcp parameter to static.  Below is my sample file, change interface name and ip details as per your environment.

# 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 primary network interface
auto enp0s3
iface enp0s3 inet static
 address 192.168.1.183
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-nameservers 8.8.8.8

save & close the file.

Interface-file-after-modification-debian11

To make above changes into the effect the restart the network service

$ sudo systemctl restart networking.service

Now, run ip command to verify the ip address,

$ ip add show

Output,

ip-address-view-debian11

That’s all from this post. Please do share your feedback and queries in below comments section.

Also Read: How to Install Kubernetes Cluster on Debian 11 with Kubeadm

1 thought on “How to Set Static IP Address on Debian 11 (Bullseye)”

  1. Nice Guide. Appreciate it.

    In case someone has used “sudo raspi-config” > Advanced Options > Network Interface Names > Would you like to enable predictable network interface names ?

    [email protected]:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.addresses 192.168.1.10/24
    [email protected]:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.gateway 192.168.1.1
    [email protected]:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.method manual
    [email protected]:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.dns ‘8.8.8.8’
    [email protected]:~ $ sudo reboot

    Reply

Leave a Comment