#ubuntu #dns #bind #resolv #nameserver #bind9 #yaml #systemd #systemctl ### **Tips for Troubleshooting DNS Issues in Ubuntu and Debian** If you're experiencing DNS resolution problems on **Ubuntu** or **Debian**, follow these steps to diagnose and fix the issue. --- ### **1. Check if `systemd-resolved` is Running** Ubuntu uses **`systemd-resolved`** for DNS management, which dynamically generates `/etc/resolv.conf`. Check its status: `sudo systemctl status systemd-resolved` - If it's **inactive or disabled**, enable and start it: `sudo systemctl enable --now systemd-resolved` --- ### **2. Restore the Symlink for `/etc/resolv.conf`** If **`systemd-resolved`** is enabled, `/etc/resolv.conf` should be a **symbolic link** pointing to `/run/systemd/resolve/resolv.conf`. Restore the symlink if it's missing: `sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf` --- ### **3. Verify `/etc/resolv.conf`** Check if `/etc/resolv.conf` exists and contains the correct nameservers: `cat /etc/resolv.conf` Expected output (example): ``` nameserver 192.168.2.2 nameserver 8.8.8.8 nameserver 1.1.1.1 search famvanderwijk.nl` ``` If **`/etc/resolv.conf`** is missing or incorrect, recreate the symlink as shown in step 2. --- ### **4. Test DNS Resolution** Check if DNS resolution is working by **pinging a domain**: `ping google.com` If you see an IP response, DNS is working. If you get **"Temporary failure in name resolution"**, DNS is still broken. --- ### **5. Reconfigure DNS in `netplan` (If Needed)** If the issue persists, try **manually configuring DNS** in your `netplan` settings. 1. **Check existing Netplan configuration**: `ls /etc/netplan/` 2. **Edit the Netplan file** (e.g., `50-cloud-init.yaml`): `sudo nano /etc/netplan/50-cloud-init.yaml` 3. **Ensure correct DNS settings** (example): ``` network: version: 2 ethernets: eth0: dhcp4: yes nameservers: addresses: [192.168.2.2, 8.8.8.8, 1.1.1.1] ``` 1. **Apply the Netplan changes**: `sudo netplan apply` --- ### **Final Steps** - **Restart networking services**: `sudo systemctl restart systemd-networkd` - **Flush the DNS cache** (if applicable): `sudo systemd-resolve --flush-caches` 🚀 **Your DNS should now be working properly!** ✅ [[TEST DNS]] [[DNS Bind, Managing the BIND DNS Service on Ubuntu]] [[DNS Bind, Managing the BIND DNS Service on Ubuntu]] [[DNS Query Reconstructed]] [[DNS UNBOUND]]