5 Commits
3 changed files with 108 additions and 10 deletions
+99 -7
View File
@@ -1,6 +1,6 @@
### ISC BIND9 Container (Stable: 9.14.3_xx) built on top of Alpine
### Last update: 6-26-19
### Latest Stable Docker Tag: 9.14.3-r0
### ISC BIND9 Container (Stable: 9.14.8_xx) built on top of Alpine
### Last update: 2-6-20
### Latest Stable Docker Tag: 9.14.8-r5
NOTE: "Last Update" is the date of the latest DockerHub build.
@@ -11,20 +11,22 @@ It is ideal for an extremely secure and fast master (authoritative server),
slave, recursive server/resolver, RPZ "dns firewall", or just
about any other purpose you can use bind for.
# Security - always on the latest stable BIND release!
To get started quickly, skip to step "D".
# (A.) Security - always on the latest stable BIND release!
This container will _always_ be up to date on the latest
stable+patched version, usually within 24 hours of it being available
in Alpine. In fact, most of the BIND vulnerabilities so far have been
reported by me to the Alpine developers.
# How to deploy a Bind (DNS) server?
# (B.) How to deploy a Bind (DNS) server?
This container contains everything needed in terms of configuration to
run as an authoritative server or a recursive resolver/forwarding cacher.
However, the default config permits queries and recursion only from 127.0.0.1 - which will not be too useful :)
But the assumption is that you will override ```/etc/bind``` with your configs, and ```/var/cache/bind``` with your zones.
# Required "DATA" directory - for configs and zone data:
# (C.) Required "DATA" directory - for configs and zone data:
This container assumes you have a "/DATA" folder with with your container specific data.
(You can change that folder, sub-folders, and file points as needed, but make sure you update the "-v" mounts for the run.)
@@ -39,7 +41,7 @@ A "/DATA/var/cache/bind" directory for all of the master or slave zones. If it's
```
# How to run a BIND ("named") Docker Container?
# (D.) How to run a BIND ("named") Docker Container?
## Default Example:
This is just to test it out - by default only allows queries from
@@ -79,3 +81,93 @@ ventz/bind
Additional options may be passed to the bind daemon via the `OPTIONS` argument, provided as:
`docker run --env OPTIONS='...'
# (E.) FAQs
## How do I generate an RNDC Key?
```
docker run -it --rm --entrypoint "/usr/sbin/rndc-confgen" ventz/bind
```
Take the portion that looks like this and save to "/etc/bind/rndc.key":
```
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-sha256;
# Note: the secret will be different, this is just an example
secret "zjVC59ehGxbbB6OhYhGaqUTIXu8Imcg3VKzvoMwIMzY=";
};
```
## What configuration files do I need to get started?
I highly recommend reading more about bind if this is your question. Here are some useful resources:
* https://www.bind9.net/manuals
* https://wiki.debian.org/Bind9
* https://help.ubuntu.com/community/BIND9ServerHowto
* https://www.zytrax.com/books/dns/ch7/
* https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-ubuntu-18-04
That said, as a bare minimum (and depending on what you want - recursive, authoritative, etc), you need:
[note: all of these are provided in `container/configs` folder]
1.) Main config: `/etc/bind/named.conf`
2.) Options: `/etc/bind/named.conf.options` (note: sane and secure defaults for recursive! If for authoritative, turn off recursive at least!)
3.) Local zones: `/etc/bind/named.conf.local` (for your zone configs if authoritative/slave/etc)
4.) Optional: `/etc/bind/named.conf.rfc1918` (for your RFC1918 "private IP" zone definitions - this is optional, and while recommended, you may comment out the last line in `named.conf.local` that utilizes it)
5.) Optional: `/etc/bind/default-zones` (folder for rfc1918 definitions - not needed if `named.conf.rfc1918` is not used)
## How do I log everything:
1.) Add to your `named.conf`:
```
...
include "/etc/bind/named.conf.logging";
...
```
and
2.) Create a file `named.conf.logging` with:
```
logging {
channel stdout {
stderr;
severity info;
print-category no;
print-severity no;
print-time yes;
};
# Customize categories as needed
# To log everything, keep at least "default"
category security { stdout; };
category queries { stdout; };
category dnssec { stdout; };
category xfer-in { stdout; };
category xfer-out { stdout; };
category default { stdout; };
};
For more information, see: https://www.slideshare.net/MenandMice/bind-9-logging-best-practices
## How do I just change Bind STDERR to STDOUT logging?
There is now a "BIND_LOG" ENV (environment) variable for logging
Environment variables can both have a default and be customized at run time.
```
"-g" = (default) Run the server in the foreground and force all logging stderr.
"-f" = Run the server in the foreground
```
By default, the "-g" value is set, as that logs all to STDERR.
You can now override it with "-f" by passing `-e "BIND_LOG=-f"` to `docker run`
+6 -1
View File
@@ -1,7 +1,12 @@
FROM alpine:latest
EXPOSE 53 53/udp
RUN apk --update upgrade && apk add bind bind-tools
RUN apk --update upgrade && apk add bind bind-tools bind-plugins
# BIND Log Options - you can override at run time
# "-g" = (default) Run the server in the foreground and force all logging stderr.
# "-f" = Run the server in the foreground
env BIND_LOG -g
# /etc/bind needs to be owned by root, group owned by "bind", and chmod 750
# since we are mounting, do it manually
+3 -2
View File
@@ -4,5 +4,6 @@ chown -R root:named /etc/bind /var/run/named
chown -R named:named /var/cache/bind
chmod -R 770 /var/cache/bind /var/run/named
chmod -R 750 /etc/bind
# Run in foreground and log to STDERR (console):
exec /usr/sbin/named -c /etc/bind/named.conf -g -u named $OPTIONS
# By default - run in foreground and log to STDERR (console)
# can be changed by running container with: -e "BIND_LOG=-f"
exec /usr/sbin/named -c /etc/bind/named.conf $BIND_LOG -u named $OPTIONS