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 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

Prevent resolv.conf changing on Linux Mint

Problem: default resolv.conf file looks like this:



#Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

#DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

#127.0.0.53 is the systemd-resolved stub resolver.

#run “systemd-resolve –status” to see details about the actual nameservers.

nameserver 127.0.0.53


But what I want is my own list of DNS servers this machine knows about regardless of what the stupid router knows.

nameserver 1.1.1.1,8.8.8.8
nameserver 127.0.0.53

But DHCP client OVERWRITES THE FILE every time you twitch. reboot, drop wifi/start wiki, change VPN service, etc, every action causes the resolv.conf file to be re-written. VERY ANNOYING.

HOW TO FIX:

Prevent your dhcp client from being able to write the resolv.conf file. Otherwise you have to ferret out how to configure what its actually doing to write. I’m too lazy. Here’s a workaround.

Create hook to avoid /etc/resolv.conf file update

You need to create /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate file under a Debian / Ubuntu Linux:


sudo vi /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate

Append following code into this nodnsupdate file:

#!/bin/sh
make_resolv_conf(){
	:
}

Save and close the file. Set permissions using the chmod command:

sudo chmod +x /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate

Now you can edit the resolv.conf file and it will stay put the way you want it.



WHY DO I DO THIS?



I am running as a server with a static IP address so I can ssh to the machine because I know its IP address. I dont want each office I go to to have to tell the machine its local IP address and DNS servers.
Just use google, opendns, cloudflare, etc etc. Not your local rinky-dink farm country coop dns server in Nebraska wasteland.

They made linux be too much like a microsoft user appliance.

Where might a server will not work? In a coffee shop! But I dont take this server to a coffee shop. I have an appliance laptop for that.

I have maybe 20 servers in my campus, and will be adding some at the western site. they are mostly IOT automation servers made up of raspberry pi computers. I need to log onto them from my desk. and I need to log onto each of them from one of the others, and vice versa. Each machoine has their pre-assigned static IP address, and of course each has a host name.

But the network manager gobbedygook the millenials added to linux is MADDENINGLY COMPLEX AND STUPID.

At my western location i do not have admin control of what the router does. Solution: put in my own surrogate router. But why? No, its just easier to use static IP addresses and and not use DHCP at all.









About reductio ad absurdum.

The “absurd” conclusion of a reductio ad absurdum argument can take a range of forms, as these examples show:

  • The Earth cannot be flat; otherwise, we would find people falling off the edge.
  • There is no smallest positive rational number because, if there were, then it could be divided by two to get a smaller one.

The first example argues that denial of the premise would result in a ridiculous conclusion, against the evidence of our senses. The second example is a mathematical proof by contradiction (also known as an indirect proof[7]), which argues that the denial of the premise would result in a logical contradiction (there is a “smallest” number and yet there is a number smaller than it)


Aristotle clarified the connection between contradiction and falsity in his principle of non-contradiction, which states that a proposition cannot be both true and false.


Professor of Theology at Denver Seminary Doug Groothius says of this:

“When people are thoroughly addled, reductio ad absurdum arguments do not work on them. This is because they themselves are already absurd and embrace absurdities as part of their nature and the nature of reality outside themselves. See Isaiah 5:20; Romans 1:18-32.”

My observations is most of those in the Q-Anon movement embrace absurdities as part of their nature.


Romans 1:18-32

God’s Wrath on Unrighteousness

18 For kthe wrath of God lis revealed from heaven against all ungodliness and unrighteousness of men, who by their unrighteousness suppress the truth. 19 For what can be mknown about God is plain to them, because God has shown it to them. 20 For his invisible attributes, namely, his eternal power and divine nature, nhave been clearly perceived, ever since the creation of the world,7 in the things that have been made. So they are without excuse. 21 For although they knew God, they did not honor him as God or give thanks to him, but they obecame futile in their thinking, and their foolish hearts were darkened. 22 pClaiming to be wise, they became fools, 23 and qexchanged the glory of rthe immortal God for images resembling mortal man and birds and animals and creeping things.

24 Therefore sGod gave them up in the lusts of their hearts to impurity, to tthe dishonoring of their bodies among themselves, 25 because they exchanged the truth about God for ua lie and worshiped and served the creature rather than the Creator, vwho is blessed forever! Amen.

26 For this reason wGod gave them up to xdishonorable passions. For their women exchanged natural relations for those that are contrary to nature; 27 and the men likewise gave up natural relations with women and were consumed with passion for one another, ymen committing shameless acts with men and receiving in themselves the due penalty for their error.

28 And since they did not see fit to acknowledge God, zGod gave them up to aa debased mind to do bwhat ought not to be done. 29 They were filled with all manner of unrighteousness, evil, covetousness, malice. They are full of envy, murder, strife, deceit, maliciousness. They are gossips, 30 slanderers, haters of God, insolent, haughty, boastful, inventors of evil, disobedient to parents, 31 foolish, faithless, heartless, ruthless. 32 Though they know cGod’s righteous decree that those who practice such things ddeserve to die, they not only do them but egive approval to those who practice them.