A Linux extension that adds support to the /etc/resolver/[suffix]
. It supports different "nameservers" to specific suffixes. It emulates the corresponding native functionality from Mac OS X.
This is still a work in progress!
Download and install the appropriate package for your Linux distribution here.
First: install https://azk.io.
And after that:
$ git clone [email protected]:azukiapp/libnss-resolver.git
# or
$ git clone https://github.com/azukiapp-samples/libnss-resolver
$ cd libnss-resolver
# build
# [so] options: debian8-0, ubuntu[12|14|15|16], fedora20, fedora23
$ azk shell [so]
# using ubuntu[12|14|15|16] or debian8-0 as [so]:
# run tests
$ azk start dns # Run a mock dns server for testing
$ azk shell [so] -t -c "scons run-test"
# or debug
$ azk shell [so] -t -c "scons run-test -Q define=DEBUG"
# install local
$ azk shell [so] -c "scons install"
# using fedora20 or fedora23 as [so]:
# run tests
$ azk start dns # Run a mock dns server for testing
$ azk shell [so] -t -c "scons run-test -Q prefix=/usr/lib64"
# or debug
$ azk shell [so] -t -c "scons run-test -Q define=DEBUG -Q prefix=/usr/lib64"
# install local
$ azk shell [so] -c "scons install -Q prefix=/usr/lib64"
Now you can add the resolver-nss in a resolution pipe:
$ sudo sed -i -re 's/^(hosts: .*files)(.*)$/\1 resolver\2/' /etc/nsswitch.conf
or edit /etc/nsswitch.conf
:
# normally ↓
hosts: files resolver dns
# but, if you have avahi (Zeroconf) installed
# ↓
hosts: files resolver mdns4_minimal [NOTFOUND=return] dns mdns4 resolver
Dependencies: scons and clang
$ git clone [email protected]:azukiapp/libnss-resolver.git
# or
$ git clone https://github.com/azukiapp/libnss-resolver.git
$ cd libnss-resolver
# build
$ scons local-install
# or, if you're using Fedora as SO
$ scons local-install -Q prefix=/usr/lib64
Now you can add the resolver-nss in a resolution pipe:
$ sudo sed -i -re 's/^(hosts: .*$)/\1 resolver/' /etc/nsswitch.conf
or edit /etc/nsswitch.conf
:
# normally ↓
hosts: files resolver dns
# but, if you have avahi (Zeroconf) installed
# ↓
hosts: files resolver mdns4_minimal [NOTFOUND=return] dns mdns4 resolver
After installing you can create many suffix
zones in /etc/resolver/
, like:
$ echo "nameserver 127.0.0.1:5353" | sudo tee -a /etc/resolver/test.resolver
Installing dnsmasq is a good way to test it:
$ sudo yum install dnsmasq
$ dnsmasq --bind-interfaces -p 5353 --no-daemon --address=/test.resolver/127.0.0.1
Now you can try this:
# ping sufix
$ ping test.resolver
# or any "subdomain"
$ ping any.test.resolver
This project uses clang for compiling, scons for mounting and valgrind for analyzing code runtime.
All of these tools are actually available behind the azk. So just use the commands below to get a development environment:
$ azk start dns
# [so] options: debian8-0, ubuntu12, ubuntu14, fedora20, fedora23
$ azk shell [so] -t -c "scons local-install"
# or, if [so] == fedora20 or fedora23
$ azk shell [so] -t -c "scons local-install -Q prefix=/usr/lib64"
After that, the following scons targets are available:
# using debian8-0, ubuntu12, ubuntu14 or ubuntu15 as so
# build and run tests
$ scons run-test -Q [define=DEBUG] [valgrind="valgrind options"]
# install in azk instance
$ scons local-install
# test:
$ ping test.resolver
# using fedora20 or fedora23 as so
# build and run tests
$ scons run-test -Q prefix=/usr/lib64 -Q [define=DEBUG] [valgrind="valgrind options"]
# install in azk instance
$ scons local-install -Q prefix=/usr/lib64
# test:
$ ping test.resolver
- Inspiration code: https://github.com/danni/docker-nss
- Mac OS X resolver feature: https://developer.apple.com/library/...
- Simple c-ares example: https://gist.github.com/mopemope/992777
- Using a dns server in c-ares: https://github.com/bagder/c-ares/blob/master/adig.c
- Ip and port formats: https://sourceware.org/bugzilla/show_bug.cgi?id=14242
- Using blocks in linux: http://mackyle.github.io/blocksruntime/
"Azuki", "Azk" and the Azuki logo are copyright (c) 2013-2016 Azuki Serviços de Internet LTDA.
Azk source code is released under Apache 2 License.
Check LEGAL and LICENSE files for more information.