The “new” way to configure your network in Ubuntu 18.04 Bionic Beaver is to use netplan files in /etc/netplan/ instead of the age-old /etc/network/ .
For some reason, /etc/network still exists and you get no warning that whatever you specify there will be ineffective.
Personally, I renamed the single file in /etc/netplan/ to something that has no bearing with “cloud” and then specified my preferred network configuration. I even removed cloud-init . Here is an example:
root@sol:/etc# cat /etc/netplan/55-network-interfaces.yaml network: ethernets: enp3s0: dhcp4: true enp4s0: addresses: [192.168.1.254/24] dhcp4: false gateway4: 192.168.1.1 nameservers: addresses: [220.127.116.11,18.104.22.168] version: 2 renderer: networkd
That sets one interface to DHCP, and the other one to a static IP address (there are two interfaces on this machine called enp3s0 and enp4s0).
Then you need to execute
sudo netplan apply and that should apply your new configuration. It does apply except that there’s one potential catch: If you’re not using the built-in systemd stub resolver, then things don’t quite work (/etc/systemd/resolve.conf with DNSStubListener=No) since the /etc/resolv.conf file is a symlink to:
To fix this, I modified the symlink to point instead to the file that netplan automatically updates: /run/systemd/resolve/resolv.conf
sudo mv /etc/resolv.conf /etc/resolv.conf.orig sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Then the correct dns servers will be fetched from netplan whenever you execute
One thought to “Ubuntu 18.04 Chronicles: Static DNS settings without Stub Resolver”
Tnx for this one. It was a time saver. Clean and easy.