DNS in container not working every time after reboot

I have a script that creates a container and installs AdGuard Home in the container. Once done, I change my router’s DNS IP to that of my host and reboot the host system.

Generally I have internet after reboot is done, but I have noticed that this is not happening all the time. Some times I reboot and it seems like the DNS is not working, and in fact I have no connection to the internet.

If I reboot again, I might or might not have a connection to the internet. What I noticed is that when I don’t have internet, and restart the DNS container, internet comes back up. So all it takes is a container restart to get it back to working. I would like to avoid this and have DNS and internet immediately once the machine has rebooted.

Anyone had a similar scenario? Any help how I can debug this? I’m at a loss, I’ve spent a whole week trying to different scenarios and restarting the system and sometimes I still have no connection to the internet.

Some other details:

  1. System running rasbian lite and container running debian/11/armhf

  2. When I don’t have connection, the container is running, has an IP and also adguard status shows that it is running.

  3. Ports forwarded for the DNS container:

proxy53T:
    connect: tcp:127.0.0.1:53
    listen: tcp:10.0.0.4:53
    type: proxy
  proxy53U:
    connect: udp:127.0.0.1:53
    listen: udp:10.0.0.4:53
    type: proxy
  proxy80:
    connect: tcp:127.0.0.1:80
    listen: tcp:10.0.0.4:80
    type: proxy
  proxy443:
    connect: tcp:127.0.0.1:443
    listen: tcp:10.0.0.4:443
    type: proxy
  proxy3000:
    connect: tcp:127.0.0.1:3000
    listen: tcp:10.0.0.4:3000
    type: proxy
  proxy8080:
    connect: tcp:127.0.0.1:8080
    listen: tcp:10.0.0.4:10301
    type: proxy
  proxy51820:
    connect: udp:127.0.0.1:51820
    listen: udp:10.0.0.4:51820
    type: proxy

The next time the issue occurs I would suggest confirming this statement:

“Some times I reboot and it seems like the DNS is not working,”

That is important as every other diagnosis step depends on that being true.
It also depends on understanding specifically where DNS isn’t working, e.g. is it not working from your host to your container, or from your network to your container or from the container out to the internet.

Beyond the proxy device config you’ve not yet supplied sufficient config detail to guess at the issue.
You would need to explain further which client machines are using your DNS service provided by the container. Is it just the LXD host or is it other devices on the network?

I suggest using the ping and dig tools on the host and inside the container to track where the problem is, and once you know then we can try and figure out whats causing it.

Hi @tomp, thank you for your reply.

I meant after reboot, I don’t get internet connection on the host, ( the host DNS is the same as it’s IP. The router’s DNS are updated to match the server’s IP ) From another PC with the host IP as it’s DNS has no internet too.

The problem is that I don’t get the same results after every reboot. Sometimes I reboot again and internet is working. Also when I reboot and the internet doesn’t work, if I restart the dns container with lxc restart container, internet connection works. I want to avoid having to restart the container.

How can I test and debug network connection? How can I know which part of the connection has the issue?

As for the configuration, I change the router DNS to that of my server ip. So I reboot / reset the devices to get the new DNS ( server’s ). This happens also for the server itself, the DNS changes to it’s own IP