# Disabling NetworkManager DNS for shared connection

**URL:** <https://forums.balena.io/t/disabling-networkmanager-dns-for-shared-connection/3737>\
**Category:** Product support\
**Created:** [August 14, 2018, 8:27pm UTC](https://forums.balena.io/t/disabling-networkmanager-dns-for-shared-connection/3737 "2018-08-14T20:27:47Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [August 16, 2018, 12:41pm UTC](https://forums.balena.io/t/disabling-networkmanager-dns-for-shared-connection/3737/10 "2018-08-16T12:41:09Z")

</div>

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](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](https://forums.balena.io/t/route-wireless-to-wired-with-resinos-2-x-and-rpi-3/3219/6)

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](https://github.com/oblique/create_ap)

Hope that is helpful 😉

---

_[View the full topic](https://forums.balena.io/t/disabling-networkmanager-dns-for-shared-connection/3737)._
