BETTER NETWORKING FOR UBUNTU

DISABLE NETWORK-MANAGER

systemctl list-unit-files | grep -i network

disable the roden

systemctl status NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager

SETUP

Define a hostname

vi /etc/hostname # short name is fine
hostname HOSTNAME # idem
vi /etc/hosts # long name FOLLOWED BY short name

Switch back to the old school /etc/network/interfaces (unless you prefer netplan)

apt update
apt install net-tools ifupdown

rmdir /etc/network/interfaces.d/
#mv /etc/network/interfaces.d/50-cloud-init.cfg /etc/network/interfaces.fuck.the.cloud-init.cfg
mv /etc/network/interfaces /etc/network/interfaces.dist

and proceed with a typical Debian network setup e.g. for a server

vi /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address x.x.x.x/xx
    gateway x.x.x.x
    dns-nameservers 62.210.16.6 62.210.16.7
    # dns-nameservers 208.67.222.222 208.67.220.220
    # dns-search example.local

otherwise for a workstation

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto wlan0
iface wlan0 inet manual

Apply, check that your local and caching stub-resolver points to your true validating resolver

systemctl restart networking
ifconfig
systemd-resolve --status

and see next section for disabling netplan at boot time

Eventually disable UFW

ufw disable
apt purge ufw

and if you really need to enable system firewalling see Netfilter with NFTABLES

FIREWALL

Eventually setup Netfilter with NFTABLES to allow only outbound connections

    dpkg -l | grep iptables
    apt purge iptables
    apt install nftables
    mv -i /etc/nftables.conf /etc/nftables.conf.dist
    vi /etc/nftables.conf

see NFTABLES SETUP and enable

    systemctl start nftables
    systemctl enable nftables
    systemctl status nftables

ADDITIONAL NOTES

disable stub-resolver

systemctl list-unit-files | grep resolv

older releases

systemctl status resolvconf
systemctl stop resolvconf
systemctl disable resolvconf

seen on artful debian9/stretch bionic

systemctl status systemd-resolved
systemctl stop systemd-resolved
systemctl disable systemd-resolved

more shit seen on a bionic dedibox

systemctl stop bind9
systemctl disable bind9
systemctl status bind9-resolvconf

good old name resolution setup

ls -lF /etc/resolv.conf*
mv /etc/resolv.conf /etc/resolv.conf.dist
vi /etc/resolv.conf

nameserver 208.67.222.222
nameserver 208.67.222.220
#search example.local

TROUBLESHOOTING

In case you get,

RTNETLINK answers: File exists

while restarting networking, look at the logs and proceed against the relevant interface,

ip addr flush dev NETIF

RESOURCES

How to install Ubuntu 17.10 (Artful Aardvark) Minimal Server - Page 2 https://www.howtoforge.com/tutorial/ubuntu-minimal-server-install/2/

Comment 7 for bug 548885 https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/548885/comments/7 –> no symlink for resolv.conf

How to make Ubuntu server 18.04 use dns-nameservers from /etc/network/interfaces? https://askubuntu.com/questions/1080230/how-to-make-ubuntu-server-18-04-use-dns-nameservers-from-etc-network-interfaces


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH