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?

Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Debian Linux |
Est. reading time | 3 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
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 192.168.3.33 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 address 192.168.3.33 netmask 255.255.255.0 gateway 192.168.3.1 dns-nameservers 1.1.1.1,8.8.8.8 save the file and exit vim Then restart networking sudo service networking restart look to see if enps05 has been re-assigned the address 192.168.3.33