Redis backed DNS Server written in GO
Find a file
2019-11-11 10:01:52 -06:00
docker Rearchitecture of server code to handle cnames, mx records, etc. 2017-06-16 22:05:36 -05:00
scripts Rearchitecture of server code to handle cnames, mx records, etc. 2017-06-16 22:05:36 -05:00
upstart Add upstart config example 2014-12-12 22:44:22 -06:00
.gitignore Ignore makefile 2016-05-10 11:20:42 -05:00
Dockerfile Rearchitecture of server code to handle cnames, mx records, etc. 2017-06-16 22:05:36 -05:00
go.mod The resolver is case-insitive, the responder maintains case of question 2018-09-14 17:37:01 -05:00
go.sum The resolver is case-insitive, the responder maintains case of question 2018-09-14 17:37:01 -05:00
handler.go Turn off recursion for AWS AUP 2019-11-11 10:01:52 -06:00
LICENSE.txt An inagural GO project, redis backed DNS 2014-12-12 22:18:42 -06:00
lookup.go The resolver is case-insitive, the responder maintains case of question 2018-09-14 17:37:01 -05:00
main.go Improve wildcard handling 2018-06-15 17:09:26 -05:00
README.md The resolver is case-insitive, the responder maintains case of question 2018-09-14 17:37:01 -05:00
record.go Rearchitecture of server code to handle cnames, mx records, etc. 2017-06-16 22:05:36 -05:00
response.go Handle A requests that only have Cnames 2017-06-29 10:39:58 -05:00
server.go Rearchitecture of server code to handle cnames, mx records, etc. 2017-06-16 22:05:36 -05:00
Vagrantfile Additional Work on Vagrant / Docker 2015-06-13 19:23:03 -05:00

Redis Powered DNS Server in GoLang

This is a DNS server that uses Redis as the backend. Redis records are stored according to the FQDN (with trailing dot) as the key, and a JSON payload as the value.

JSON Payload:

{
    "cnames": ["foo-12345.example.com."],
    "fqdn": "foo-12345.example.com.",
    "id": 27469,
    "ipv4_public_ips": ["104.0.0.1"],
    "ipv6_public_ips": [],
    "mbox": "admin.example.com."
    "mx_servers": [],
    "name_servers": ["ns1.example.com", "ns2.example.com"],
    "soa": "example.com"
    "ttl": 300,
}
  • supply cnames or ipv4_public_ips, not both
  • mbox admin.example.com # Don't use '@' in DNS email addresses
  • wildcard records, eg. www.foo-12345.example.com. are supported. The Redis key for wildcards is *.foo-12345.example.com..

Usage:

./redis-dns-server \
    -redis-server-url redis://127.0.0.1:6379 \
    -port 5300

Port 53 is the standard port. Using a port less than 1024 will require root privileges.

Development

Building

General build steps:

Download from github and build using golang 1.11 Dependencies are automatically installed


$ go build
$ ./redis-dns-server --help

Using Vagrant

A simple Vagrantfile is provided to quickly spin up an Ubuntu 14.04 LTS box, that already has GoLang installed, as well as the latest version of Docker, and Docker Compose.


$ vagrant up
$ vagrant ssh

Inside Vagrant, the current working project directory will be accessible at /vagrant.

Using Docker and Docker Compose

Either from your local machine running Docker, or from within the Vagrant box:


$ cp -a docker-compose.env.example docker-compose.env
$ docker-compose up

To rebuild the image manually:


$ docker-compose build

Deployment

Docker

Reference the above Development section for using Docker Compose. Alternatively, Redis DNS Server can be deployed with Docker in the following fashion.

Building


$ make linux
$ docker build -t 'redis-dns-server:latest' .

Linking With a Redis Container


$ docker run -tid --name redis redis
$ docker run -itd \
    -e DOMAIN="example.com" \
    -e HOSTNAME="myhostname.example.com" \
    --link redis:db \
    -p 53:53 \
    redis-dns-server:latest

Linking With an External Redis Server


$ docker run -itd \
    -e DOMAIN="example.com" \
    -e HOSTNAME="myhostname.example.com" \
    -e REDIS_HOST="redis.example.com" \
    -p 53:53 \
    redis-dns-server:latest

Using an Environment File

You can load all ENV variables from an ENV file. An example ENV file can be found at docker-compose.env.example, and looks something like:


REDIS_HOST=redis.example.com
REDIS_PORT=6379
REDIS_DB=0
REDIS_USERNAME=myuser
REDIS_PASSWORD=mypassword
DOMAIN=example.com
DOMAIN_EMAIL=admin.example.com
HOSTNAME=myhostname.example.com

Using it:

$ docker run -itd \
    --env-file /path/to/myenv.file \
    -p 53:53 \
    redis-dns-server:latest

Inspiration:

TODO List: