is there any label to mount /etc/resolv.dnsmasq

I want to access the actual DNS server used by the device and IIUC this is basically defined in /etc/resolv.dnsmasq (istead of conventional resolv.conf)
I tried to mount it directly in docker compose via volume:

    volumes:
      - /etc/resolv.dnsmasq:/app/host-resolv.conf

but balena deploy has failed with: Bind mounts are not allowed

I found out that this can be fixed by some label but I did not found anything that fit from this list.

Basically what I want to do is for resolv.dnsmasq be copied to a container on start, not copy it when building because if it’s buulding on some random CI runner it would be useless.

Nothing about it in ouside-of-container and multicontainer setup. The only relevant thing I found is this dnsmasq mention

Is it possible or are there another ways to figure out the first upstream DNS server(s) other way?
via supervisor API, dbus, anything?

Hi, obtaining the DNS servers that are being used is a bit more difficult. BalenaOS supports three different DNS settings:

  • The default DNS servers
  • DHCP provided DNS servers - these are the ones stored by NetworkManager in /etc/resolv-conf.dnsmasq
  • User configured DNS servers

dnsmasq will then query all configured servers in parallel and use the first response.

So querying dnsmasq is probably the only robust way to obtain this information. You can query dnsmasq d-bus API but unfortunately it does not offer a GetServers endpoint.

The only thing I can think of is to issue a USR1 signal to dnsmasq so that it dumps the information and fetch it from the logs.

Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: time 1713952323
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: cache size 150, 0/292 cache insertions re-used unexpired cache entries.
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: queries forwarded 104, queries answered locally 268
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: queries for authoritative zones 0
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: pool memory in use 0, max 0, allocated 0
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: server 8.8.8.8#53: queries sent 65, retried or failed 0
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: server 80.58.61.250#53: queries sent 73, retried or failed 0
Apr 24 09:52:03 cb1438e dnsmasq[2202]: dnsmasq[2202]: server 80.58.61.254#53: queries sent 46, retried or failed 0

However, there is no standard interface to access the system logs from a container so this might not be a clean solution.