Debian 11 Static Networking

I have a Debian 11 Linux cloud server, and it is configured to get it’s IP addresses from it’s local router via DHCP. How do I convert DHCP address capability to instead use a static IP address setting?

See all Debian/Ubuntu Linux related FAQ

Tutorial details
Difficulty levelEasy
Root privilegesYes
RequirementsDebian Linux
Est. reading time3 minutes

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.

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

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

Configure a static IP address for enp0s5 Ethernet interface at address

sudo cd /etc/network
Backup /etc/network/interfaces file 
 sudo cp interfaces interfaces.orig
Edit the /etc/network/interfaces
sudo vim interfaces

Then find the lines and remove or comment out:
allow-hotplug enp0s5
iface enp0s5 inet dhcp

Add lines:

# the following line is vital  for a "service networking restart" to assign the interface
auto enps05

#this next line assigns the actual interface
iface inet enps05 static

save the file and exit vim

Then restart networking
sudo service networking restart

look to see if enps05 has been re-assigned the address

Facebook friends may comment