Disabling NetworkManager DNS for shared connection

You were right about NetworkManager spawning a new dnsmasq instance when setting connection mode to shared. This runs on the same IP that you need pi-hole’s dnsmasq instance to run, so the port will not be available indeed. Manual option is the correct one for this case.

My suggestions would be:

  1. For connection sharing there are two possibilities NAT and bridged. I think you will be better off for your use case with NAT. This is also what NetworkManager does in its shared mode.

  2. Install pi-hole in a recent Debian container. Usually I go with either Stretch or even the unstable Buster if I have issues on Stretch.

  3. I looked at pi-hole’s installer. It checks for nmcli availability. nmcli is the command line interface of NetworkManager. It communicates with NetworkManager through D-Bus. You may install NetworkManager inside the container, so that the installer invokes nmcli. However do not forget to mask the NetworkManager’s service: RUN apt-get update && apt-get install -y network-manager && systemctl mask NetworkManager.service. You will need also to export the correct DBUS_SYSTEM_BUS_ADDRESS address, so that nmcli communicates with the NM service running on the host OS. More information on this here: https://docs.resin.io/reference/OS/network/2.x/#changing-the-network-at-runtime

  4. If you are running a multicontainer setup you need to set docker compose network_mode to host.

  5. Investigate what the pi-hole installer does, as it may well set networking for your use case. I have not done that, so I am not sure whether it will do that or not.

  6. Here is another topic related to Internet connection sharing that you may find useful which includes a sample repo from a forum user: Route Wireless to Wired with resinOS 2.x and RPi 3

  7. You may find useful the create_ap script, which is for creating Access Points with Internet sharing (it uses hostapd instead of the lightweight built-in access point NetworkManager creates, but it can still be useful for creating the AP, or as a reference at least): https://github.com/oblique/create_ap

Hope that is helpful :wink:

1 Like