the most fundamental networking settings are ever changing
it used to be /etc/resolv.conf
where nameservers are set
systemd is doing it’s own thing
and Ubuntu (based on Debian) is doing (again) it’s entirely own thing (netplan)
frankly: this sucks X-D
annoys and confuses users that just “want to set primary dns” in 3 sec not 30min to figure out what system is doing what how.
/etc/resolv.conf should stay what it is X-D (via #comment in first line it could be defined what program is in charge of the file and that’s it, not every system comes with it’s own network config file and it’s own syntax… just agree on one syntax (can also be written as #this config file uses this and that syntax in version x and leave it at /etc/resolv.conf)
the crazy shortcut (but it works)
vim /scripts/debian/dns/permanent_overwrite_resolv.conf.sh; # create new script #!/bin/bash # unfortunately the dns system is a mess (every distro doing it's thing, multiple network managers confuse even more who is handling what how) # so simply overwrite /etc/resolv.conf every 3 seconds with while true; do echo "nameserver 220.127.116.11" > /etc/resolv.conf ; # https://ipfire.org 's dns server (works pretty well :) good job! echo "nameserver 18.104.22.168" >> /etc/resolv.conf ; # https://libredns.gr 's nameserver cat /etc/resolv.conf; sleep 3; clear; done # how to run it su - root chmod +x /scripts/debian/dns/permanent_overwrite_resolv.conf.sh /scripts/debian/dns/permanent_overwrite_resolv.conf.sh
to auto start this
re-activate rc.local (the file that used to be started on startup)
after reboot check if it wirks:
cat /etc/resolv.conf nameserver 22.214.171.124 nameserver 126.96.36.199
the long and probably dysfunctional way
hostnamectl; # tested on Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-17-amd64 Architecture: x86-64 su - root; # become root # find the network manager of evil dpkg -l|grep network ii network-manager 1.14.6-2+deb10u1 amd64 network management framework (daemon and userspace tools) ii network-manager-gnome 1.8.20-1.1 amd64 network management framework (GNOME frontend) # remove all network managers (except systemd, can not remove that X-D) apt remove *network-manager* apt remove *wicd* # check what interface to configure (primary interface enp2s0) ip -c a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 # make a backup of the config file (just in case) # backup the Debian primary network config file mkdir -p /backup/etc/network cp -rv /etc/network/interfaces /backup/etc/network/interfaces # backup the systemd primary network config file cp -rv /etc/systemd/resolved.conf /backup/etc/network/interfaces # systemd based systems vim /etc/systemd/resolved.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See resolved.conf(5) for details [Resolve] DNS=188.8.131.52 FallbackDNS=127.0.0.1 ::1 #Domains= #LLMNR=yes #MulticastDNS=yes #DNSSEC=allow-downgrade DNSOverTLS=yes #Cache=yes #DNSStubListener=yes #ReadEtcHosts=yes # how it used to be vim /etc/network/interfaces # in Debians prior to systemd (so guess all the dns-nameserver settings here will be ignored? X-D) # 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 # === enp2s0:config primary network interface with dhcp === allow-hotplug enp2s0 iface enp2s0 inet dhcp # + custom primary (!) dns server dns-nameservers 184.108.40.206 # + CloudFlare DNS as fallback dns-nameservers 220.127.116.11 # === enp2s0:0 === # add another fixed ip (virtual interface:0) address to this interface for easier lan networking auto enp2s0:0 allow-hotplug enp2s0:0 iface enp2s0:0 inet static address 192.168.3.222 netmask 255.255.255.0 # gateway 192.168.3.1 auto enp2s0:1 allow-hotplug enp2s0:1 iface enp2s0:1 inet static address 192.168.4.222 netmask 255.255.255.0 # gateway 192.168.4.1 auto enp2s0:2 allow-hotplug enp2s0:2 iface enp2s0:2 inet static address 192.168.5.222 netmask 255.255.255.0 # gateway 192.168.5.1 :wq # test the settings service networking restart # check if it worked ip -c a # check if systemd updated resolv.conf cat /etc/resolv.conf # 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 nameserver 18.104.22.168 # test if routing is working ping 22.214.171.124 # test if dns is working host yahoo.com yahoo.com has address 126.96.36.199 yahoo.com has address 188.8.131.52 yahoo.com has address 184.108.40.206 yahoo.com has address 220.127.116.11 yahoo.com has address 18.104.22.168 yahoo.com has address 22.214.171.124 yahoo.com has IPv6 address 2001:4998:24:120d::1:0 yahoo.com has IPv6 address 2001:4998:24:120d::1:1 yahoo.com has IPv6 address 2001:4998:124:1507::f001 yahoo.com has IPv6 address 2001:4998:44:3507::8001 yahoo.com has IPv6 address 2001:4998:44:3507::8000 yahoo.com has IPv6 address 2001:4998:124:1507::f000 yahoo.com mail is handled by 1 mta5.am0.yahoodns.net. yahoo.com mail is handled by 1 mta7.am0.yahoodns.net. yahoo.com mail is handled by 1 mta6.am0.yahoodns.net.
test if LibreDNS is working:
browse to: https://libredns.gr/
https://wiki.debian.org/NetworkConfiguration (Debian’s documentation always has been … complicated … but better than none X-D)
to confuse users even more: nmtui (used to be a Fedora/RedHat/CentOS only network config tool is there in ubuntu too!