Code Monkey home page Code Monkey logo

docker-bind's Introduction

Bind Docker

Tag lint build nightly License

Discord Discourse

Available Architectures: amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le

Bind caching DNS server based on Alpine and Debian slim with support for DNS forwarders, infinite wild-card DNS, infinite extra hosts, reverse DNS, DNSSEC timing settings and others.

Bind Project Reference Implementation
Bind DNS Server The Devilbox

๐Ÿ‹ Available Docker tags

latest stable alpine

docker pull cytopia/bind

Rolling Releases

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker Tag Git Ref Available Architectures
latest master amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le
stable master amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le
alpine master amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le

Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker Tag Git Ref Available Architectures
<tag> git: <tag> amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le
<tag>-stable git: <tag> amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le
<tag>-alpine git: <tag> amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x, mips64le

๐Ÿ›ˆ Where <tag> refers to the chosen git tag from this repository.
โš  Warning: The latest available git tag is also build every night and considered a rolling tag.


Table of Contents

  1. Environment variables
    1. Required environment variables
    2. Optional environment variables
      1. DEBUG_ENTRYPOINT
      2. DOCKER_LOGS
      3. DNS_A
      4. DNS_CNAME
      5. DNS_PTR
      6. DNSSEC_VALIDATE
      7. DNS_FORWARDER
      8. MAX_CACHE_SIZE
      9. TTL_TIME
      10. REFRESH_TIME
      11. RETRY_TIME
      12. EXPIRY_TIME
      13. MAX_CACHE_TIME
      14. ALLOW_QUERY
      15. ALLOW_RECURSION
  2. Volumes
  3. Exposed Ports
  4. Examples
    1. Default run
    2. Wildcard domain
    3. Wildcard subdomain
    4. Wildcard TLD
    5. Wildcard TLD and reverse DNS entry
    6. Wildcard TLD and DNS resolver
    7. Wildcard TLD, DNS resolver and extra hosts
    8. Extra hosts, DNS resolver, allow query, and allow recursion
  5. Host integration
  6. Sister Projects
  7. Community
  8. Articles
  9. Credits
  10. Maintainer
  11. License

โˆ‘ Environment Variables

Required environment variables

  • None

Optional environment variables

Variable Type Default Description
DEBUG bool 0 Set to 1 in order to add set -x to entrypoint script for bash debugging
DEBUG_ENTRYPOINT bool 0 Show shell commands executed during start.
Values: 0, 1 or 2
DOCKER_LOGS bool 0 Set to 1 to log info and queries to Docker logs.
DNS_A string Comma separated list of A records (wildcard supported).
DNS_CNAME string Comma separated list of CNAME records (wildcard supported).
DNS_PTR string Comma separated list of PTR records (reverse DNS).
DNSSEC_VALIDATE string no Control the behaviour of DNSSEC validation. The default is to not validate: no. Other possible values are: yes and auto.
DNS_FORWARDER string Specify a comma separated list of IP addresses as custom DNS resolver. This is useful if your LAN already has a DNS server which adds custom/internal domains and you still want to keep them in this DNS server
Example: DNS_FORWARDER=8.8.8.8,8.8.4.4
MAX_CACHE_SIZE size 90% Amount of memory used by the server (cached results)
TTL_TIME int 3600 (time in seconds) see bind ttl and bind soa
REFRESH_TIME int 1200 (Time in seconds) See BIND SOA
RETRY_TIME int 180 (Time in seconds) See BIND SOA
EXPIRY_TIME int 1209600 (Time in seconds) See BIND SOA
MAX_CACHE_TIME int 10800 (Time in seconds) See BIND SOA
ALLOW_QUERY string Specify a comma separated list of IP addresses with optional CIDR mask to allow queries from a specific IP address or ranges of IP addresses. This allows for control over who is allowed to query the DNS server. If not specified all hosts are allowed to make queries (defaults to any). See BIND QUERIES
Example: ALLOW_QUERY=192.168.1.0/24,127.0.0.1
ALLOW_RECURSION string Specify a comma separated list of IP addresses with optional CIDR mask to allow queries from a specific IP address or ranges of IP addresses. This option allows this DNS server to forward a request to another DNS server when an address cannot be resolved. If not present the allow-query-cache default is assumed. See BIND QUERIES
Example: ALLOW_RECURSION=192.168.1.0/24,127.0.0.1

DEBUG_ENTRYPOINT

  • If set to 0, only warnings and errors are shown
  • If set to 1, info, warnings and errors are shown
  • If set to 2, info, warnings and errors are shown, as well as commands executed during startup

DOCKER_LOGS

  • If set to 0, no additional logging is done during run-time
  • If set to 1, BIND is more verbose during run-time and shows asked queries as well as general information

DNS_A

The DNS_A option allows you to specify one or more A records (including wildcard if required) which can either be a full TLD, a domain or any kind of subdomain. It allows you to map your Domain to a specific IP address.

The general format is as follows:

# Structure
DNS_A='tld1=1.1.1.1, tld2=2.2.2.2, *.tld3=3.3.3.3'

Some examples:

# 1. One entry:
# The following catches all queries to *.tld (wildcard) and redirects them to 192.168.0.1
DNS_A='*.tld=192.168.0.1'

# 2. Two entries:
# The following catches all queries to *.tld and redirects them to 192.168.0.1
# As well as all queries from *.example.org and redirects them to 192.168.0.2
DNS_A='*.tld=192.168.0.1, *.example.org=192.168.0.2'

DNS_CNAME

The DNS_CNAME option allows you to specify one or more CNAME records (including wildcard if required) which can either be a full TLD, a domain or any kind of subdomain. It allows you to map your Domain to a specific IP address.

The general format is as follows:

# Structure
DNS_CNAME='tld1=google.com, tld2=www.google.com, *.tld3=example.org'

Some examples:

# 1. Using CNAME's for resolving:
# The following catches all queries to *.tld and redirects them to whatever
# IP example.org resolved to
DNS_CNAME='*.tld=example.org'

DNS_PTR

The DNS_PTR option allows you to specify PTR records (reverse DNS).

The general format is as follows:

# Structure
DNS_PTR='192.168.0.1=www.google.com, 192.168.0.2=ftp.google.com'

Some examples:

# 1. Adding reverse DNS:
# The following adds reverse DNS from 192.168.0.1 to resolve to tld
DNS_PTR='192.168.0.1=tld'

DNSSEC_VALIDATE

The DNSSEC_VALIDATE variable defines the DNSSEC validation. Default is to not validate (no). Possible values are:

  • yes - DNSSEC validation is enabled, but a trust anchor must be manually configured. No validation will actually take place.
  • no - DNSSEC validation is disabled, and recursive server will behave in the "old fashioned" way of performing insecure DNS lookups, until you have manually configured at least one trusted key.
  • auto - DNSSEC validation is enabled, and a default trust anchor (included as part of BIND) for the DNS root zone is used.

DNS_FORWARDER

By default this dockerized BIND is not acting as a DNS forwarder, so it will not have any external DNS available. In order to apply external DNS forwarding, you will have to specify one or more external DNS server. This could be the one's from google for example (8.8.8.8 and 8.8.4.4) or any others you prefer. In case your LAN has its own DNS server with already defined custom DNS records that you need to make available, you should use them.

# Structure (comma separated list of IP addresses)
DNS_FORWARDER='8.8.8.8,8.8.4.4'

Some examples

DNS_FORWARDER='8.8.8.8'
DNS_FORWARDER='8.8.8.8,192.168.0.10'

MAX_CACHE_SIZE

The amount of RAM used by the server to store results. You can use relative (percent) or absolute (bytes) values. Examples:

  • MAX_CACHE_SIZE=30% (Use 30% of the systems memory)
  • MAX_CACHE_SIZE=512M (Use 512 Megabytes)
  • MAX_CACHE_SIZE=2G (Use 2 Gigabytes)

TTL_TIME

Specify time in seconds. For more information regarding this setting, see BIND TTL and BIND SOA

REFRESH_TIME

Specify time in seconds. For more information regarding this setting, see BIND SOA

RETRY_TIME

Specify time in seconds. For more information regarding this setting, see BIND SOA

EXPIRY_TIME

Specify time in seconds. For more information regarding this setting, see BIND SOA

MAX_CACHE_TIME

Specify time in seconds. For more information regarding this setting, see BIND SOA

ALLOW_QUERY

By default this dockerized BIND does not specify query rules. This exposes the allow-query options to specify who is allowed to query for results. Note that ACLs are not yet handled.

# Structure (comma separated list of IP addresses, IP addresses with CIDR mask, or address match list names "none", "any", "localhost", and "localnets")
ALLOW_QUERY='192.168.1.0/24,127.0.0.1'

Some examples

ALLOW_QUERY='any'
ALLOW_QUERY='192.168.1.0/24,127.0.0.1'

ALLOW_RECURSION

By default this dockerized BIND does not allow DNS recursion. If BIND cannot resolve an address it will act as a DNS client and forward the request to another DNS server. This server is specified in the DNS_FORWARDER list. Note that ACLs are not yet handled.

# Structure (comma separated list of IP addresses, IP addresses with CIDR mask, or address match list names "none", "any", "localhost", and "localnets")
ALLOW_RECURSION='192.168.1.0/24,127.0.0.1'

Some examples

ALLOW_RECURSION='any'
ALLOW_RECURSION='192.168.1.0/24,127.0.0.1'

๐Ÿ“‚ Volumes

  • None

๐Ÿ–ง Exposed Ports

Docker Description
53 DNS Resolver
53/udp DNS Resolver

๐Ÿ’ก Examples

The following examples start the container in foreground and use -i, so you can easily stop it by pressing <Ctrl> + c. For a production run, you would rather use -d to send it to the background.

Default run

Exposing the port is mandatory if you want to use it for your host operating system.

docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -t cytopia/bind

Wildcard domain

Let's add a wildcard zone for *.example.com. All subdomains (but not example.com itself) will resolve to 192.168.0.1.

docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.example.com=192.168.0.1' \
    -t cytopia/bind

Wildcard subdomain

Let's add a wildcard zone for *.aws.example.com. All subdomains (but not aws.example.com itself) will resolve to 192.168.0.1.

docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.aws.example.com=192.168.0.1' \
    -t cytopia/bind

Wildcard TLD

Let's add a wildcard zone for *.loc. All domains, subdomain (but not loc itself) will resolve to 192.168.0.4.

docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.loc=192.168.0.4' \
    -t cytopia/bind

Wildcard TLD and reverse DNS entry

Let's add a wildcard zone for *.loc, and an A record for loc. All domains, subdomain and loc itself will resolve to 192.168.0.4. Additionally we specify that host.loc will be the reverse loopup for 192.168.0.4.

docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.loc=192.168.0.4, loc=192.168.0.4' \
    -e DNS_PTR='192.168.0.4=host.loc' \
    -t cytopia/bind

Wildcard TLD and DNS resolver

Let's add a wildcard zone for *.loc. All its domains (but not the domain itself) will resolve to 192.168.0.4.

Let's also hook in our imaginary corporate DNS server into this container, so we can make use of any already defined custom DNS entries by that nameserver.

  • loc and all its subdomains (such as: hostname.loc) will point to 192.168.0.1:
  • Your corporate DNS servers are 10.0.15.1 and 10.0.15.2
docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.loc=192.168.0.1' \
    -e DNS_FORWARDER=10.0.15.1,10.0.15.2 \
    -t cytopia/bind

Wildcard TLD, DNS resolver and extra hosts

  • All subdomains of loc (but not loc itself) will point to 192.168.0.1
  • Your corporate DNS servers are 10.0.15.1 and 10.0.15.2
  • Also add two additional hosts with A and PTR records:
    • host5.loc -> 192.168.0.2
    • host5.org -> 192.168.0.3
docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='*.loc=192.168.0.1, host5.loc=192.168.0.2, host5.org=192.168.0.3' \
    -e DNS_PTR='192.168.0.2=host5.loc, 192.168.0.3=host5.org' \
    -e DNS_FORWARDER=10.0.15.1,10.0.15.2 \
    -t cytopia/bind

Extra hosts, DNS resolver, allow query, and allow recursion

  • Your trusted external DNS servers are 8.8.8.8 and 8.8.4.4 (google DNS servers)
  • Allow queries from:
    • All 192.168.0.xxx addresses
    • Localhost aka 127.0.0.1
  • Allow recursion to resolve other queries (such as www.google.com) from:
    • All 192.168.0.xxx addresses
    • Localhost aka 127.0.0.1
  • Add an extra hosts with custom DNS:
    • host1 -> 192.168.0.11
docker run -i \
    -p 53:53/tcp \
    -p 53:53/udp \
    -e DNS_A='host1=192.168.0.11' \
    -e DNS_FORWARDER=8.8.8.8,8.8.4.4 \
    -e ALLOW_QUERY=192.168.0.0/24,127.0.0.1 \
    -e ALLOW_RECURSION=192.168.0.0/24,127.0.0.1 \
    -t cytopia/bind

๐Ÿ”ง Host integration

You can run this DNS container locally without having to worry to affect any corporate DNS server that are given to you via DHCP.

Add the following line to the very beginning to /etc/dhcp/dhclient.conf:

prepend domain-name-servers 127.0.0.1;

Restart network manager

# Via service command
sudo service network-manager restart

# Or the systemd way
sudo systemctl restart network-manager

This will make sure that whenever your /etc/resolv.conf is deployed, you will have 127.0.0.1 as the first entry and also make use of any other DNS server which are deployed via the LAN's DHCP server.

If cytopia/bind is not running, it does not affect the name resolution, because you will still have entries in /etc/resolv.conf.

๐Ÿ–ค Sister Projects

Show some love for the following sister projects.

๐Ÿ–ค Project ๐Ÿฑ GitHub ๐Ÿ‹ DockerHub
Devilbox
docker-php-fpm devilbox/php-fpm
docker-php-fpm-community devilbox/php-fpm-community
docker-mysql devilbox/mysql
docker-apache-2.2
docker-apache-2.4
docker-nginx-stable
docker-nginx-mainline
devilbox/apache-2.2
devilbox/apache-2.4
devilbox/nginx-stable
devilbox/nginx-mainline
docker-bind cytopia/bind

๐Ÿ‘ซ Community

In case you seek help, go and visit the community pages.

devilbox.readthedocs.io discord/devilbox devilbox.discourse.group

๐Ÿ“œ Articles

โค๏ธ Credits

Thanks for contributing ๐Ÿ–ค

๐Ÿง˜ Maintainer

@cytopia

I try to keep up with literally over 100 projects besides a full-time job. If my work is making your life easier, consider contributing. ๐Ÿ–ค

Findme: ๐Ÿฑ cytopia / devilbox | ๐Ÿ‹ cytopia / devilbox | ๐Ÿฆ everythingcli / devilbox | ๐Ÿ“– everythingcli.org

Contrib: PyPI: cytopia ยท Terraform: cytopia ยท Ansible: cytopia

๐Ÿ—Ž License

MIT License

Copyright (c) 2022 cytopia

docker-bind's People

Contributors

atomicbaum1 avatar cytopia avatar dependabot[bot] avatar dvlbot avatar ericp-mrel avatar zighy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-bind's Issues

DNSSEC problems with DNS forwarders

Hello,

I am working with https://github.com/cytopia/devilbox and had everything working yesterday.

I can't find anything in today's update that could have caused this, but the bind container is giving back DNSSEC errors whenever I have a dns forwarder set:

Apr 20 19:21:03 00015d8a4ceb named[1]: broken trust chain resolving 'google.com/A/IN': 192.168.1.10#53
Apr 20 19:21:03 00015d8a4ceb named[1]: validating ./NS: no valid signature found
Apr 20 19:21:03 00015d8a4ceb named[1]: no valid RRSIG resolving './NS/IN': 192.168.1.11#53
Apr 20 19:21:03 00015d8a4ceb named[1]: validating ./NS: no valid signature found
Apr 20 19:21:03 00015d8a4ceb named[1]: no valid RRSIG resolving './NS/IN': 199.7.91.13#53
Apr 20 19:21:03 00015d8a4ceb named[1]: validating ./NS: no valid signature found

I have gone into the container, and turned off dnssec verification and that seems to make it work.

echo " dnssec-validation off;"

echo " dnssec-validation auto;"

If you know of anything that may have changed, that would be helpful.

Or if we could add an ENV variable to turn off DNSSEC validation?

Do you have any other ideas on how this could be resolved?

Thanks!

Completely disable recursion

First of all, awesome quality image; very well done!

I was wondering how to disable recursion? The docs say it's disabled by default but it is still resolving?

docker run --rm -ti \
-p 5553:53/tcp \
-p 5553:53/udp \
-e DNS_A='test.domain=1.2.3.4' \
-t cytopia/bind

dig @127.0.0.1 -p 5553 test.domain

; <<>> DiG 9.10.6 <<>> @127.0.0.1 -p 5553 test.domain
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6228
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;test.domain. IN A

;; ANSWER SECTION:
test.domain. 5 IN A 1.2.3.4

dig @127.0.0.1 -p 5553 google.com

; <<>> DiG 9.10.6 <<>> @127.0.0.1 -p 5553 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51124
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;google.com. IN A

;; ANSWER SECTION:
google.com. 300 IN A 142.251.39.110

AWS ALB CNAME support

I tried adding a CNAME to EXTRA_HOSTS and it bombs with...

Invalid IP address 'internal-foo-bar-baz-1234567890.us-east-1.elb.amazonaws.com': for sandbox.example.com -> internal-foo-bar-baz-1234567890.us-east-1.elb.amazonaws.com. Skipping to add extra host

Based on the error message, maybe the is_cname isn't picking this up properly?

query failed (REFUSED) with version (tag) 0.16

Hi,
I just updated to use the 0.16 docker image from 0.15, but was getting errors like this on any dns forwarded queries;

bind9   | 10-Jun-2019 11:36:29.603 client @0x7fe3d817f860 192.168.1.10#54157 (www.reddit.com): query: www.reddit.com IN A +E(0) (172.19.0.2)
bind9   | 10-Jun-2019 11:36:29.604 client @0x7fe3d817f860 192.168.1.10#54157 (www.reddit.com): query (cache) 'www.reddit.com/A/IN' denied
bind9   | 10-Jun-2019 11:36:29.604 client @0x7fe3d817f860 192.168.1.10#54157 (www.reddit.com): query failed (REFUSED) for www.reddit.com/IN/A at ../../../bin/named/query.c:7145

The extra hosts and wildcard queries works fine, but all forwarded queries gets that error.
I had to rollback to 0.15, where everything works fine.

My config looks like this;

version: '2.1'
services:
  bind:
    image: cytopia/bind:0.15
    container_name: bind9
    restart: unless-stopped
    environment:
      - TZ=Europe/Oslo
      - WILDCARD_DNS=anon.xyz=192.168.1.5
      - EXTRA_HOSTS=sheets.anon.xyz=anon.github.io
      - DNS_FORWARDER=208.67.222.222,208.67.220.220,192.168.1.1,8.8.8.8
      - DOCKER_LOGS=1
      - TTL_TIME=300
    ports:
      - "53:53"
      - "53:53/udp"

[Question]: How do i use host.docker.internal while this service is active

Have you already checked elsewhere?

  • I have checked existing issues
  • I have googled already with no luck
  • I have not done any of the above

What is your question?

I need to use xdebug to debug something in php. Normally you can use the special DNS name 'host.docker.internal' from docker to connect xdebug to the host system. But when cytopia/bind is active xdebug can't establish a connection. If I disable cytopia/bind, it's working. Is there something I need to configure to make this work while cytopia/bind is active?

What have you tried already?

Different environment configurations.

What is your goal?

Make xdebug work.

Cannot route all subdomains to an IP except the domain itself

Hello
The way the WILDCARD_DNS parameter is used we cannot use it without having to map the domain aswell,
and using something like *.DOMAIN.com is not supported by the system,

how would I let domain.com handled by normal dns (8.8.8.8 for example) and all its subdomain handled by bind ?

Thanks

xargs: unmatched single quote

I am getting the following error when running the container:

$ docker-compose up
Creating network "docker-bind_default" with the default driver
Creating docker-bind_bind_1 ... done
Attaching to docker-bind_bind_1
bind_1  | [INFO] Debug level: 1
bind_1  | [INFO] Using default DNS TTL time: 3600 sec
bind_1  | [INFO] Using default DNS Refresh time: 1200 sec
bind_1  | [INFO] Using default DNS Retry time: 180 sec
bind_1  | [INFO] Using default DNS Expiry time: 1209600 sec
bind_1  | [INFO] Using default DNS Max Cache time: 10800 sec
bind_1  | xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
docker-bind_bind_1 exited with code 1

I used the following docker-compose.yml to run it:

version: '2'

services:
  bind:
    build: .
    restart: always
    ports:
      - "53:53/udp"
      - "53:53/tcp"
    environment:
      - WILDCARD_DNS='loc=192.168.1.103'

[Bug]: timeout when run in no internet network enviroment

(Optional) Error message

No response

What went wrong?

when query domain,time out happen.

nslookup cas.wow.cn 10.2.10.147 ;; connection timed out; no servers could be reached

Expected behaviour

query dns server ,return domain's ip address.

How can we reproduce the bug?

  • the docker image cytopia/bind in private harbor repository
  • the server(10.2.10.147) in interal network enviroment,could't reach internet
  1. start a docker container on centos 7
    docker run --restart=always -d -p 53:53/tcp -p 53:53/udp -e DNS_A='*.wow.cn=10.2.10.125' -e DOCKER_LOGS=1 -e ALLOW_QUERY=any -t harbor.xxx.com/cytopia/bind

  2. query the dns server ip
    nslookup cas.wow.cn 10.2.10.147
    ;; connection timed out; no servers could be reached

Host Operating System

Linux

Host Platform (amd64, arm64, other)

amd64

(Linux only) Is SELinux enabled?

No, SELinux is disabled

Docker version

20.10.22

Log: docker logs

/etc/bind/custom/zone/rpz
--------------------------------------------------------------------------------
$TTL 3600
@                               IN   SOA     090be6331014. admin.090be6331014. (
                                             1673478408     ; Serial number
                                             1200           ; Refresh time
                                             180            ; Retry time
                                             1209600        ; Expiry time
                                             10800          ; Negative Cache TTL
)

; NS Records
                                IN   NS      090be6331014.

; Custom Records
*.wow.cn                     IN   A       10.2.10.125
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] Starting BIND 9.16.33
11-Jan-2023 23:06:48.275 managed-keys-zone: loaded serial 0
11-Jan-2023 23:06:48.276 zone 0.in-addr.arpa/IN: loaded serial 1
11-Jan-2023 23:06:48.278 zone rpz/IN: loaded serial 1673478408
11-Jan-2023 23:06:48.278 rpz: rpz: reload start
11-Jan-2023 23:06:48.278 rpz: rpz: reload done
11-Jan-2023 23:06:48.281 zone localhost/IN: loaded serial 2
11-Jan-2023 23:06:48.281 zone 127.in-addr.arpa/IN: loaded serial 1
11-Jan-2023 23:06:48.282 zone 255.in-addr.arpa/IN: loaded serial 1
11-Jan-2023 23:06:48.283 all zones loaded
11-Jan-2023 23:06:48.283 running
12-Jan-2023 03:22:55.017 client @0x7f7888850f70 172.17.0.1#57150 (225.8.2.10.in-addr.arpa): query: 225.8.2.10.in-addr.arpa IN PTR + (172.17.0.2)
12-Jan-2023 03:25:02.049 client @0x7f7888850f70 10.2.10.147#58112 (cas.wow.cn): query: cas.wow.cn IN A + (172.17.0.2)
12-Jan-2023 03:25:07.049 client @0x7f7888864730 10.2.10.147#58112 (cas.wow.cn): query: cas.wow.cn IN A + (172.17.0.2)
12-Jan-2023 03:25:12.049 client @0x7f7888864730 10.2.10.147#58112 (cas.wow.cn): query: cas.wow.cn IN A + (172.17.0.2)
12-Jan-2023 03:25:12.050 resolver priming query complete
12-Jan-2023 03:25:22.051 resolver priming query complete
12-Jan-2023 03:25:22.051 client @0x7f7888850f70 10.2.10.147#58112 (cas.wow.cn): query failed (timed out) for cas.wow.cn/IN/A at query.c:7375
12-Jan-2023 03:26:58.518 client @0x7f788000c090 172.17.0.1#47826 (cas.wow.cn): query: cas.wow.cn IN A + (172.17.0.2)

(Optional) Additional information

No response

Building zone files fails for the debian image in docker compose

Building the zone file from the DNS_A environment variable seems to fail in the debian image (tag latest) when the container was created by docker compose. When creating a container from the command line, everything works fine, when creating it via docker compose, the hostname -A command here seems to be returning a hostname containing a space (2e520b409724 2e520b409724 in the log below), messing up the zone file syntax.

I don't have any explanation for why hostname would return different things depending on if the container was created by compose or not or why this problem only occurs for debian and not for alpine. Switching to the alpine tag worked as a workaround for me.

dns_1  | [ERR]  Configuration failed.
dns_1  | dns_rdata_fromtext: /etc/bind/custom/zone/rpz:2: near 'admin.2e520b409724': not a valid number
dns_1  | dns_rdata_fromtext: /etc/bind/custom/zone/rpz:11: near '2e520b409724.': extra input text
dns_1  | zone rpz/IN: loading from master file /etc/bind/custom/zone/rpz failed: not a valid number
dns_1  | zone rpz/IN: not loaded due to errors.
dns_1  |
dns_1  | --------------------------------------------------------------------------------
dns_1  | /etc/bind/custom/conf/rpz.conf
dns_1  | --------------------------------------------------------------------------------
dns_1  | zone "rpz" IN {
dns_1  |     type master;
dns_1  |     allow-transfer { any; };
dns_1  |     allow-update { any; };
dns_1  |     file "/etc/bind/custom/zone/rpz";
dns_1  | };
dns_1  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dns_1  |
dns_1  | --------------------------------------------------------------------------------
dns_1  | /etc/bind/custom/zone/rpz
dns_1  | --------------------------------------------------------------------------------
dns_1  | $TTL 3600
dns_1  | @                               IN   SOA     2e520b409724 2e520b409724. admin.2e520b409724 2e520b409724. (
dns_1  |                                              1654539831     ; Serial number
dns_1  |                                              1200           ; Refresh time
dns_1  |                                              180            ; Retry time
dns_1  |                                              1209600        ; Expiry time
dns_1  |                                              10800          ; Negative Cache TTL
dns_1  | )
dns_1  |
dns_1  | ; NS Records
dns_1  |                                 IN   NS      2e520b409724 2e520b409724.
dns_1  |
dns_1  | ; Custom Records
dns_1  | <domain>               IN   A       <ip>

Option for "forward only" ?

I would like to use docker-bind as a caching, forwarding only dns server.

Would it be possible to add an option to add "forward only;" to named.conf.options ?

[Feature]: Statistics Channel enable

What is your idea or feature suggestion?

Would love to see an environment variable to initialize statistics-channels

Benefits

No response

Where can we find information about this?

No response

Are you willing to provide a PR to address this?

None

problem with reverse resolution and multiple EXTRA_HOSTS

following the readme, I try to resolve two hosts like below

docker service create \
  --name bind-dns \
  -p 53:53/tcp \
  -p 53:53/udp \
  -e EXTRA_HOSTS='hetzner1=10.8.0.5=hetzner1,hetzner2=10.8.0.9=hetzner2' \
  cytopia/bind

and I get following log with error error - docker service fails

bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Debug level: 1
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Using default DNS TTL time: 3600 sec
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Using default DNS Refresh time: 1200 sec
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Using default DNS Retry time: 180 sec
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Using default DNS Expiry time: 1209600 sec
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Using default DNS Max Cache time: 10800 sec
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Adding extra host: hetzner1 -> 10.8.0.5 (PTR: hetzner1)
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Adding extra host: hetzner2 -> 10.8.0.9 (PTR: hetzner2)
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] DNSSEC Validation: no
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Adding custom DNS forwarder: 8.8.8.8,8.8.4.4
bind-dns.1.8wkm3glijglg@kimsufi1    | [INFO] Starting BIND 9.11.4
bind-dns.1.8wkm3glijglg@kimsufi1    | /etc/bind/devilbox-extra_hosts.hetzner2.conf:7: zone '0.8.10.in-addr.arpa': already exists previous definition: /etc/bind/devilbox-extra_hosts.hetzner1.conf:7

Everything is working fine with only one specified host.
If I try to define EXTRA_HOST twice, the last one wins

[Feature]: custom zone files

What is your idea or feature suggestion?

Do we have an example of using a custom zone file with this? I'd be interested in defining MX, TXT, and AAAA records.

Benefits

use crucial basic features of custom zone files for DNS

Where can we find information about this?

No response

Are you willing to provide a PR to address this?

None

More flexible CNAME/IP support for WILDCARD_DNS and EXTRA_HOSTS

Today a CNAME/IP specified for EXTRA_HOSTS/WILDCARD_DNS is assumed to be resolved to a single IP using dig @8.8.8.8 +short "${my_add}" A.

Imagine use cases:

  • A DNS entry pointing to Elastic Load Balancer, e.g. using Route53 A DNS entry with an Alias:
    example.com -> <elb_id>.<aws_region>.elb.amazonaws.com.
$ dig @8.8.8.8 +short example.com A
54.XX.XX.XX
3.XX.XX.XX
  • CNAME DNS entry pointing to Alias A DNS entry in Route53 -
    example1.com -> example.com -> <elb_id>.<aws_region>.elb.amazonaws.com.
$ dig @8.8.8.8 +short example1.com A
 example.com
54.XX.XX.XX
3.XX.XX.XX

The IP set behind load balancer is dynamic and might change a couple times a day thus it doesn't make sense to create a zone with IPs which can become stale at any time.

Suggestion:
For CNAME specified WILDCARD_DNS and EXTRA_HOSTS and resolved not to a single IP create a CNAME zone instead:

$TTL  3600
@      IN SOA  example.com. root.example.com. (
 ...
;
      IN NS     example1.com.
*     IN CNAME  example1.com.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.