Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Adds Basic Docker support #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
etc/xip-pdns.conf
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:14.04

RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get upgrade -y --force-yes && \
apt-get install -y pdns-server pdns-backend-pipe

# remove all other pdns backends
RUN rm -f /etc/powerdns/pdns.d/*

# install our source and powerdns backend configurations
ADD bin/xip-pdns /usr/local/bin/xip-pdns
ADD etc/xip-pdns.backend.conf.example /etc/powerdns/pdns.d/xip.conf

# expose dns ports
EXPOSE 53/udp 53/tcp

CMD ["pdns_server", "--master", "--daemon=no", "--local-address=0.0.0.0"]
96 changes: 91 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,95 @@
#### xip-pdns
# XIP PowerDNS Backend Adapter

This is the source of the [PowerDNS](http://powerdns.com/) pipe backend adapter powering [xip.io](http://xip.io/).
This is the source of the [PowerDNS](http://powerdns.com/) pipe backend
adapter powering [xip.io](http://xip.io/).

Install this on your system, adjust [etc/xip-pdns.conf](etc/xip-pdns.conf.example) to your liking, and configure PowerDNS as follows:
## Deploying Manually

launch=pipe
pipe-command=/path/to/xip-pdns/bin/xip-pdns /path/to/xip-pdns/etc/xip-pdns.conf
Copy `etc/xip-pdns.conf.example` to `/etc/xip-pdns.conf`, and modify to meet
your needs.

Example:

**/etc/xip-pdns.conf**

```
# Increment this timestamp when the contents of the file change.
XIP_TIMESTAMP="2014102800"

# The top-level domain for which the name server is authoritative.
XIP_DOMAIN="xip.test"

# The public IP addresses (e.g. for the web site) of the top-level domain.
# `A` queries for the top-level domain will return this list of addresses.
XIP_ROOT_ADDRESSES=( "1.2.3.1" )

# The public IP addresses on which this xip-pdns server will run.
# `NS` queries for the top-level domain will return this list of addresses.
# Each entry maps to a 1-based subdomain of the format `ns-1`, `ns-2`, etc.
# `A` queries for these subdomains map to the corresponding addresses here.
XIP_NS_ADDRESSES=( "1.2.3.4" "1.2.3.5" )

# How long responses should be cached, in seconds.
XIP_TTL=300
```

Then copy `etc/xip-pdns.backend.conf.example` to
`/etc/powerdns/pdns.d/xip.conf` (or the appropriate PowerDNS backend adapter
configuration location for your system), and modify to meet your needs.

Example:

**/etc/powerdns/pdns.d/xip.conf**

```
launch=pipe
pipe-command=/usr/local/bin/xip-pdns /etc/xip-pdns.conf
```

Finally, copy `bin/xip-pdns` to `/usr/local/bin/xip-pdns` (or wherever you
prefer).

Restart PowerDNS, and test.

```
$ dig test.10.0.0.1.xip.test @localhost
;; ANSWER SECTION:
test.10.0.0.1.xip.test. 300 IN A 10.0.0.1
```

*Note: Replace `localhost` with the address of the host running PowerDNS.*

## Deploying with Docker

XIP PDNS can easily be deployed with the included Dockerfile as follows.
First copy `etc/xip-pdns.conf.example` to `/path/to/xip-pdns.conf` (wherever
you want it), and modify for your needs. Build, and run with Docker:

```
$ cp -a etc/xip-pdns.conf.example etc/xip-pdns.conf

$ docker build -t 'xip-pdns' .

$ docker run -it \
-p 0.0.0.0:53:53/tcp \
-p 0.0.0.0:53:53/udp \
-v ./etc/xip-pdns.conf:/etc/xip-pdns.conf \
xip-pdns
```

Alternatively, the above can be run with Docker Compose using the included
`docker-compose.yml`:

```
$ docker-compose up
```

And test:

```
$ dig test.10.0.0.1.xip.test @localhost
;; ANSWER SECTION:
test.10.0.0.1.xip.test. 300 IN A 10.0.0.1
```

*Note: Replace `localhost` with the host running the Docker container.*
16 changes: 9 additions & 7 deletions bin/xip-pdns
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ set -e
shopt -s nocasematch

#
# Configuration
# Source Configuration File Defaults
#
XIP_DOMAIN="xip.test"
XIP_ROOT_ADDRESSES=( "127.0.0.1" )
XIP_NS_ADDRESSES=( "127.0.0.1" )
XIP_TIMESTAMP="0"
XIP_TTL=300

if [ -a "$1" ]; then
source "$1"
fi

#
# Configuration Default Settings (if not yet provided)
#
[ -z "$XIP_DOMAIN" ] && XIP_DOMAIN="xip.test"
[ -z "$XIP_ROOT_ADDRESSES" ] && XIP_ROOT_ADDRESSES=( "127.0.0.1" )
[ -z "$XIP_NS_ADDRESSES" ] && XIP_NS_ADDRESSES=( "127.0.0.1" )
[ -z "$XIP_TIMESTAMP" ] && XIP_TIMESTAMP="0"
[ -z "$XIP_TTL" ] && XIP_TTL=300

#
# Protocol helpers
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: '2'
services:
xip:
build: .
volumes:
- ./etc/xip-pdns.conf:/etc/xip-pdns.conf
ports:
- "53:53/tcp"
- "53:53/udp"

2 changes: 2 additions & 0 deletions etc/xip-pdns.backend.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
launch=pipe
pipe-command=/usr/local/bin/xip-pdns /etc/xip-pdns.conf