2

Setting DNS in Ubuntu

1. /etc/resolv.conf – This file was traditionally used in Ubuntu to store DNS addresses information on Linux systems. However, in Ubuntu installations since version 18.04, this file is automatically generated and managed by the systemd-resolved service. You should not edit this file directly as changes will be overwritten. 2. /etc/netplan/*.yaml – Netplan is the default network configuration utility for modern Ubuntu versions. Netplan configuration files are found in /etc/netplan with a .yaml extension. You can specify how network interfaces of the system should be configured. You can define DNS nameservers in these files. 3. /etc/systemd/resolved.conf – This file configures the systemd-resolved service, which manages DNS resolution in many modern Ubuntu systems.

2

Determine correct file

– Check if your system uses Netplan by looking for configuration files in /etc/netplan. If files exist there, use Netplan configuration. – Otherwise, check if /etc/resolv.conf points to a systemd-resolved stub. This can be identified by checking if the file contains lines like current DNS server nameserver 127.0.0.53 configuration. If so, you will need to configure DNS using systemd-resolved.

2

Netplan config not taking effect

Network Manager Overriding If you’re using a desktop environment, Network Manager might be managing network settings and overriding those specified in Netplan. – systemd-resolved Configuration: systemd-resolved might not be set to use the DNS servers specified in Netplan. Check resolved.conf and ensure it is correctly configured or the service uses Netplan’s settings. – Incorrect Syntax in YAML File: YAML files are sensitive to syntax and must be precisely formatted. Even small errors (like using tabs instead of spaces) can prevent settings from being applied.