Minimal A and NS record resolver
sudo sdns \
--port 53 \
--addr 127.0.0.11 \
'domain=test.cirocosta.io,ip=192.168.0.103,ns=mynameserver.com' \
'domain=*.cirocosta.io,ip=127.0.0.1,ip=10.0.0.10'
sudo sdns \
--debug \ # logs the requests to 'stderr'
--port 53 \
--addr 127.0.0.11 \
--recursor 8.8.8.8
Pick the latest version in the project’s releases page and then “untar” the binary to the desired location in $PATH
.
For instance:
URL=https://github.com/cirocosta/sdns/releases/download/v0.0.1/sdns_0.0.1_darwin_amd64.tar.gz
mkdir -p /tmp/sdns
curl -o /tmp/sdns/sdns.tar.gz -L $URL
tar xzfv /tmp/sdns/sdns.tar.gz -C /tmp/sdns
sudo mv /tmp/sdns/sdns /usr/local/bin/sdns
Note.: you can also use go
to install it: go get -u github.com/cirocosta/sdns
. Just make sure that you can run the binary with the necessary privileges to bind to port 53
.
Using sdns
in a Docker container is completely fine, you can find the image under cirocosta/sdns.
docker run -d \
--network host \ # use the host network stack (not required)
cirocosta/sdns \ # use the image
--debug \ # logs the requests to 'stderr'
--port 53 \
--addr 127.0.0.11 \
--recursor 8.8.8.8
Usage: sdns [--port PORT] [--address ADDRESS] [--debug] [--recursor RECURSOR] [DOMAINS [DOMAINS ...]]
Positional arguments:
DOMAINS list of domains
Options:
--port PORT, -p PORT port to listen to [default: 1053]
--address ADDRESS, -a ADDRESS
address to bind to
--debug, -d turn debug mode on [default: true]
--recursor RECURSOR, -r RECURSOR
list of recursors to honor [default: [8.8.8.8 8.8.4.4]]
--help, -h display this help and exit
If you’re on Ubuntu 17.04 you might have noticed that systemd
places a DNS resolver at 127.0.0.53
:
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
127.0.0.53
As systemd-resolve
is a systemd
service like any other, we just need to stop the unit and then place sdns
at 127.0.0.53
listening on the default DNS service port (53
):
sudo systemctl stop systemd-resolved
sudo sdns \ # run as sudo to be able to bind to 53
--debug \ # with --debug we capture more logs
--address 127.0.0.53 \ # listen on the expected IP
--port 53 # on port 53
# Now if you stop 'sdns' you'll lose DNS resolving.
# To get systemd-resolve in place again just
# issue `sudo systemctl start systemd-resolved`.
Now you can head to your web browser and see the queries coming to SDNS.
If you wish you can also run sdns
as a systemd
service (like systemd-resolved
)