This project is dedicated to enable containers on a Docker subnetwork to lookup
macOS compatible mDNS domain names by the low level Name Service Switch (NSS).
So when a request from the host system is routed into the Docker subnetwork,
with a domain like app.local.mac
and the compatibility jump host was able to
resolve the correct mDNS domain (app.local
) everything is fine. But when the
subnetwork internal applications start using the macOS compatibility domain
(.mac
suffix), things get messy. The lookup is doomed to fail, because nobody
responds to the .mac
suffix domain. Thats where this plugin jumps into. We
allow domain resolution with the .mac
suffix in place by using the Avahi
client, just like a jump host.
First you need to clone this repository from Github:
# Clone the repository
$ git clone https://github.com/hausgold/libnss-mac-mdns.git
# Go in the repository directory
$ cd libnss-mac-mdns
We assume you have prepared the requirements in advance. The only thing which is left, is to build, install and use the NSS plugin:
# Build the NSS plugin from source
$ make build
# Install the NSS plugin into your system
$ sudo make install
After the successful installation of the plugin you can configure it. Just edit
your /etc/nsswitch.conf
file with system permissions and change the hosts
configuration like this:
hosts: [..all your stuff..] mac_mdns
Just make sure that mac_mdns
is before dns
.
We assume you have a running mDNS stack on every Docker container you use,
and/or on your host system is an Avahi mDNS server running. Just make sure
your mDNS stack is working properly and can resolve domains like app.local
.
When you installed and configured the libnss-mac-mdns library, you can start
resolving .mac
suffixed domains.
# Lookup a regular mDNS domain
$ getent hosts app.local
# => 172.17.0.17
# Lookup the macOS compatibility domain
$ getent hosts app.local.mac
# => 172.17.0.17
As you can see here, we just allow both resolutions, without touching the mDNS configuration at all.
So if you like to start developing, just make your changes, and run make test
and you should be able to validate your changes. The only requirement to make
this work, is the configuration on the /etc/nsswitch.conf
file, just like
described above. (hard requirement for the tests)
Bug reports and pull requests are welcome on GitHub at https://github.com/hausgold/libnss-mac-mdns.
This project was heavily inspired by Danielle Madeley excellent docker-nss library. We also had a deeper look at the following projects to get our thing going: