0

As I'm far from an advanced network manager, please help me if you can.

Some weeks ago I 'reconfigured' my home network with a manageable DNS/DNS relay service to allow us to use home only domains instead of IP addresses (as the number of networked devices at home started to increase too much). The chosen solution was the usual 'dnsmasq' setup on my RPi (latest Ubuntu based for Home Assistant), and as a possibility I set it up also as our DHCP server instead of the previously configured router, to manage all relevant things at one place. This is my first 'dnsmasq' usage, but at the end it seemed that everything works fine... except for one thing:

When I restart the RPi, or the corresponding network services on it, all its DHCP connected clients somehow lose the DNS until their re-connection to the network again. For example, after an RPi reboot, my computer still has the previously leased IP address (and seems all the corresponding network settings), but the name resolution doesn't work further until I disconnect and reconnect my NIC to the network. Addressing with IP addresses is working further but the name resolution not. This result is also true all of my other devices (mobiles, notebooks, etc.).

After 'reconnect' everything works fine, but without it I simply cannot resolve the domain names.

Could anybody point me to the right direction what could be the reason of the problem if it is familiar?

  • Currently I use only the WiFi connection of the RPi...

  • Router/gateway IP: 192.168.1.1

  • 'netplan' config in /etc/netplan/50-cloud-init.yaml:

    # This file is generated from information provided by the datasource.  Changes
    # to it will not persist across an instance reboot.  To disable cloud-init's
    # network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: true
          optional: true
      wifis:
        wlan0:
          optional: true
          access-points:
            "***":
              password: "***"
              hidden: true
            "***":
              password: "***"
              hidden: true
          dhcp4: false
          dhcp6: false
          addresses: [192.168.1.2/24]
          routes:
            - to: default
              via: 192.168.1.1
          nameservers:
            addresses: [192.168.1.2,8.8.8.8]
    
  • All custom 'dnsmasq' settings in /etc/dnsmasq.d/ebola.conf:

    domain-needed
    bogus-priv
    no-resolv
    server=8.8.8.8
    server=4.4.4.4
    local=/home/ebola/
    dhcp-range=192.168.1.201,192.168.1.255,255.255.255.0,168h
    dhcp-option=option:router,192.168.1.1
    dhcp-lease-max=50
    dhcp-authoritative
    cache-size=5000
    
    #------------------------------
    
    dhcp-host=...(mac,hostname,ip,infinite)
    dhcp-host=...(mac,hostname,ip,infinite)
    dhcp-host=...(mac,hostname,ip,infinite)
    
  • /etc/hosts

    The devices and their IP addresses which I want to reach by their local domain names.

(Which latest requirement for me is interesting as I thought the DHCP host config section in the 'dnsmasq' config will define them, in case I define the hostnames there.)

3
  • When I was running dnsmasq on ubuntu 20.04, I had a ton of problems with the 'default' netplan network management system. I switched back to the traditional /etc/networks and its worked great. I didn't dig deeper but I suspect its a misconfiguration of netplan and dnsmasq. Try restarting just dnsmasq and see what happens, and a proper solution would be to take a look at the systemd units for both and seeing whether the dependancies are correct
    – Journeyman Geek
    Commented Jul 17, 2022 at 13:54
  • Thanks @JourneymanGeek for your fast response. What I can tell you now is the following: - After restart just 'dnsmasq' (sudo systemctl restart dnsmasq.service), there is no problem. All devices reach the net and name resolution works fine. - After restart just 'networkd' (sudo systemctl status systemd-networkd), there is no problem. All devices reach the net and name resolution works fine. - After restart the whole machine, previous clients loose name resolution until their network reconnect. In some minutes I will expand my original post with the corresponding config entries. Commented Jul 17, 2022 at 15:57
  • Sounds like the name to IP address mapping is lost on reboot until the clients refresh. The info could be lost because it isn't saved, but the service restarts would argue against that. I'm a little curious if it is lost due to the clock / timeout for time-bounded leases, knowing that the Raspb. Pi doesn't have a built-in clock. Commented Jul 17, 2022 at 16:51

1 Answer 1

0

After some weeks/months I found the following tip, which solved the problem:

https://unix.stackexchange.com/a/716330/540376

After put the mentioned fix (interface=wlan0 in my case) into my 'dnsmasq' config, my problems gone away.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .