Score:0

Netplan DNS disaster

in flag

I'm struggling to get netplan to work. (I thought I still wanted resolv.conf this does fix DNS but gets re-written on reboot.) Everything appears to be correct but I can't ping.

$ sudo netplan --debug apply
** (generate:14256): DEBUG: 00:38:22.887: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:14256): DEBUG: 00:38:22.888: starting new processing pass
** (generate:14256): DEBUG: 00:38:22.888: We have some netdefs, pass them through a final round of validation
** (generate:14256): DEBUG: 00:38:22.888: ens160: setting default backend to 1
** (generate:14256): DEBUG: 00:38:22.888: Configuration is valid
** (generate:14256): DEBUG: 00:38:22.888: Generating output files..
** (generate:14256): DEBUG: 00:38:22.888: NetworkManager: definition ens160 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:ens160 not found in {}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets:
    ens160:
      critical: true
      dhcp4: true
      dhcp4-overrides:
        use-dns: false
      dhcp6: true
      dhcp6-overrides:
        use-dns: false
      ipv6-privacy: true
      nameservers:
        addresses:
        - 10.10.11.200
        - 1.1.1.1
        search:
        - home
  vlans: {}
  wifis: {}

DEBUG:Skipping non-physical interface: lo
DEBUG:device ens160 operstate is up, not changing
DEBUG:Skipping non-physical interface: docker0
DEBUG:Skipping non-physical interface: hassio
DEBUG:Skipping non-physical interface: vethecdde1c
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for ens160
DEBUG:netplan triggering .link rules for docker0
DEBUG:netplan triggering .link rules for hassio
DEBUG:netplan triggering .link rules for vethecdde1c
$ ping google.com
ping: google.com: Temporary failure in name resolution

edits per request.

I assumed I was using netplan since it was installed.

/etc/netplan/50-cloud-init.yaml I did not create this file it was there.

network:
    ethernets:
        ens160:
            critical: true
            dhcp4: true
            dhcp4-overrides:
                use-dns: false
            dhcp6: true
            dhcp6-overrides:
                use-dns: false
            ipv6-privacy: true
            nameservers:
                search: [home]
                addresses: [10.10.11.200, 1.1.1.1]

    version: 2

When I try to the two commands I get error for both.

$ sudo systemd-resolve --status
Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found.
$ sudo resolvectl --status
sudo: resolvectl: command not found
ru flag
Are you using Netplan or NetworkManager? This here sounds a lot like NetworkManager may be taking control. Is this a Desktop or Server setup, and have you verified you aren't using any other network configuration manager like NetworkManager or otherwise to control the interfaces? Can you provide a copy of your `/etc/netplan` configuration, not just the error output here? Also the output of `systemd-resolve --status` or `resolvectl --status` depending on which Ubuntu you're on (20.04+ has `resolvectl`, 18.04 doesn't so you have to invoke via the `systemd-resolved` command)
wlraider70 avatar
in flag
@ThomasWard I added the info you requested.
us flag
$ sudo: resolvectl: command not found What Ubuntu release are you running? This command is part of systemd in 20.04 and later so should always be present. $ sudo systemd-resolve --status Why is systemd-resolved not running on your system? `systemctl status systemd-resolved`
wlraider70 avatar
in flag
version: 18.04.6
Score:0
mo flag
Nux

What you want is Dnsmasq. Netplan only allows to configure fallback DNS, not a domain DNS.

Prepare installation

  • Remove "systemd-resolved"
    • sudo systemctl disable systemd-resolved
    • sudo systemctl stop systemd-resolved
  • Remove linked resolv.conf
    • Make sure it is a link (will point to something like: ...systemd/resolve/stub-resolv.conf):
    • sudo ls -lh /etc/resolv.conf
    • Remove link:
    • sudo rm /etc/resolv.conf
  • Add temporary DNS
    • sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf
  • Install Dnsmasq
    • sudo apt update
    • sudo apt install dnsmasq

Problem with dnsmasq.d/lxd

You might get this error when dnsmasq starts initially:

dnsmasq: cannot access /etc/dnsmasq.d/lxd: No such file or directory

To resolve this just remove symlink ¯\(ツ)

sudo rm /etc/dnsmasq.d/lxd

And restart:

service dnsmasq restart
service dnsmasq status

Configure DNSmasq

Edit /etc/dnsmasq.conf.

Search and uncomment this options:

  • domain-needed
  • bogus-priv
  • strict-order
  • no-resolv

Add your domain DNS servers e.g.:

server=/mycompany.com.pl/192.168.0.123
server=/some.vlan/10.234.0.123

Add generic servers e.g.:

server=1.1.1.1
server=8.8.4.4

Restart when done:

service dnsmasq restart
service dnsmasq status

Note that status will show which DNS servers are actually used (using nameserver ...).

Final steps

  • Set DNS to local:
    • Add local DNS in resolve:
      • sudo echo "nameserver 127.0.0.1" > /etc/resolv.conf
    • Update /etc/netplan/ yaml file too.
  • Test with dig (or ping).
    • (look for ;; ANSWER SECTION:)
    • dig app01.some.vlan
    • dig server.mycompany.com.pl
  • Enable running on boot:
    • systemctl enable dnsmasq
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.