Skip to content

Commit 327deb4

Browse files
bind
1 parent be54615 commit 327deb4

File tree

16 files changed

+307
-115
lines changed

16 files changed

+307
-115
lines changed

.github/workflows/docker_build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: bind9
2+
3+
on:
4+
push:
5+
branches:
6+
-
7+
"master"
8+
9+
env:
10+
IMAGE_NAME: "bind9"
11+
VERSION: "latest"
12+
jobs:
13+
push:
14+
name: Build and push to Docker Hub
15+
runs-on: ubuntu-latest
16+
steps:
17+
-
18+
name: Checkout repository
19+
uses: actions/checkout@v3
20+
-
21+
name: Build image
22+
run: DOCKER_BUILDKIT=1 docker build . --file Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
23+
-
24+
name: Login to Docker Hub
25+
uses: docker/login-action@v2
26+
with:
27+
username: ${{ secrets.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
-
30+
name: Push Image to Docker Hub
31+
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
32+
-
33+
name: Tag image
34+
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:$(date +%Y%m%d)
35+
-
36+
name: Push tag Image to Docker Hub
37+
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:$(date +%Y%m%d)

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
tmp

Dockerfile

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,28 @@ ENV LC_ALL ru_RU.UTF-8
88
ENV MUSL_LOCPATH /usr/share/i18n/locales/musl
99

1010
RUN set -eux; \
11-
apk add --no-cache \
12-
pwgen \
13-
supervisor \
14-
bind bind-libs bind-tools bind-dnssec-tools \
15-
\
16-
musl musl-utils musl-locales \
17-
\
18-
tzdata patch; \
19-
rm -f /var/cache/apk/*; \
20-
rm -rf /etc/bind/*
11+
apk add --no-cache \
12+
pwgen \
13+
supervisor \
14+
bind bind-libs bind-tools bind-dnssec-tools \
15+
\
16+
musl musl-utils musl-locales \
17+
\
18+
tzdata patch; \
19+
rm -f /var/cache/apk/*; \
20+
rm -rf /etc/bind/*
2121

2222
COPY bind /etc/bind
2323
COPY supervisor /etc/supervisor
2424
COPY entrypoint /usr/sbin/entrypoint
2525

2626
RUN set -eux; \
27-
mkdir /var/log/named; \
28-
chown -R named:named /var/log/named/ /etc/bind/*; \
29-
chmod +x /usr/sbin/entrypoint
27+
mkdir /var/log/named; \
28+
chown -R named:named /var/log/named/ /etc/bind/*; \
29+
chmod +x /usr/sbin/entrypoint; \
30+
find /etc/bind -name ".gitkeep" -type f -delete
3031

31-
EXPOSE 53 953
32+
33+
VOLUME [ "/etc/bind" ]
34+
EXPOSE 53 953 8080
3235
ENTRYPOINT [ "entrypoint" ]
33-
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# docker bind9
2+
3+
[![bind9](https://github.com/RootShell-coder/docker-bind9/actions/workflows/docker_build.yml/badge.svg?branch=master)](https://github.com/RootShell-coder/docker-bind9/actions/workflows/docker_build.yml)
4+
5+
6+
_Split horizon DNS with bind9 and auto update named.root_
7+
8+
`wget https://raw.githubusercontent.com/RootShell-coder/docker-bind9/master/docker-compose.yml`
9+
10+
```yml
11+
version: '3.9'
12+
13+
networks:
14+
named:
15+
name: named
16+
driver: bridge
17+
ipam:
18+
driver: default
19+
config:
20+
- subnet: 172.18.0.0/24
21+
gateway: 172.18.0.1
22+
23+
volumes:
24+
bind_conf:
25+
name: bind_conf
26+
27+
services:
28+
bind:
29+
image: rootshellcoder/bind9
30+
networks:
31+
- named
32+
volumes:
33+
- bind_conf:/etc/bind
34+
environment:
35+
- TZ=Europe/Moscow
36+
- LOCALE=ru_RU
37+
- CRON_HINT_FILE='https://www.internic.net/domain/named.root'
38+
- CRON_HINT_TIME='0 1 1 * * *'
39+
ports:
40+
- 8080:8080/tcp
41+
- 953:953/tcp
42+
- 172.18.0.1:53:53/tcp
43+
- 172.18.0.1:53:53/udp
44+
```
45+
46+
`docker compose up -d`
47+
48+
## external
49+
50+
51+
`dig @172.18.0.2 A www.example.com`
52+
53+
```
54+
; <<>> DiG 9.16.33-RH <<>> @172.18.0.2 A www.example.com
55+
; (1 server found)
56+
;; global options: +cmd
57+
;; Got answer:
58+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62115
59+
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
60+
;; WARNING: recursion requested but not available
61+
62+
;; OPT PSEUDOSECTION:
63+
; EDNS: version: 0, flags:; udp: 1232
64+
; COOKIE: 952b3f0fc7790d800100000063e2e88b5d94b21e949f3fa0 (good)
65+
;; QUESTION SECTION:
66+
;www.example.com. IN A
67+
68+
;; ANSWER SECTION:
69+
www.example.com. 600 IN A 172.18.0.2
70+
71+
;; Query time: 1 msec
72+
;; SERVER: 172.18.0.2#53(172.18.0.2)
73+
;; WHEN: Wed Feb 08 03:10:51 MSK 2023
74+
;; MSG SIZE rcvd: 88
75+
76+
```
77+
78+
## internal
79+
80+
`docker ps`
81+
82+
```
83+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84+
5e3ac0fffef2 bind "entrypoint" 8 seconds ago Up 7 seconds 0.0.0.0:953->953/tcp, :::953->953/tcp, 172.18.0.1:53->53/tcp, 172.18.0.1:53->53/udp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp bind-bind-1
85+
```
86+
`docker exec -ti 5e sh`
87+
88+
`dig @127.0.0.1 A www.example.com`
89+
```
90+
; <<>> DiG 9.18.11 <<>> @127.0.0.1 A www.example.com
91+
; (1 server found)
92+
;; global options: +cmd
93+
;; Got answer:
94+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18309
95+
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
96+
97+
;; OPT PSEUDOSECTION:
98+
; EDNS: version: 0, flags:; udp: 1232
99+
; COOKIE: 4d85bbef62daa5060100000063e2e77396f1603a0441514d (good)
100+
;; QUESTION SECTION:
101+
;www.example.com. IN A
102+
103+
;; ANSWER SECTION:
104+
www.example.com. 600 IN A 127.0.0.1
105+
106+
;; Query time: 0 msec
107+
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
108+
;; WHEN: Wed Feb 08 03:06:11 MSK 2023
109+
;; MSG SIZE rcvd: 88
110+
```

bind/bind.keys

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,3 @@
1-
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2-
#
3-
# SPDX-License-Identifier: MPL-2.0
4-
#
5-
# This Source Code Form is subject to the terms of the Mozilla Public
6-
# License, v. 2.0. If a copy of the MPL was not distributed with this
7-
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
8-
#
9-
# See the COPYRIGHT file distributed with this work for additional
10-
# information regarding copyright ownership.
11-
12-
# The bind.keys file is used to override the built-in DNSSEC trust anchors
13-
# which are included as part of BIND 9. The only trust anchors it contains
14-
# are for the DNS root zone ("."). Trust anchors for any other zones MUST
15-
# be configured elsewhere; if they are configured here, they will not be
16-
# recognized or used by named.
17-
#
18-
# To use the built-in root key, set "dnssec-validation auto;" in the
19-
# named.conf options, or else leave "dnssec-validation" unset. If
20-
# "dnssec-validation" is set to "yes", then the keys in this file are
21-
# ignored; keys will need to be explicitly configured in named.conf for
22-
# validation to work. "auto" is the default setting, unless named is
23-
# built with "configure --disable-auto-validation", in which case the
24-
# default is "yes".
25-
#
26-
# This file is NOT expected to be user-configured.
27-
#
28-
# Servers being set up for the first time can use the contents of this file
29-
# as initializing keys; thereafter, the keys in the managed key database
30-
# will be trusted and maintained automatically.
31-
#
32-
# These keys are current as of Mar 2019. If any key fails to initialize
33-
# correctly, it may have expired. In that event you should replace this
34-
# file with a current version. The latest version of bind.keys can always
35-
# be obtained from ISC at https://www.isc.org/bind-keys.
36-
#
37-
# See https://data.iana.org/root-anchors/root-anchors.xml for current trust
38-
# anchor information for the root zone.
39-
401
trust-anchors {
412
# This key (20326) was published in the root zone in 2017.
423
. initial-key 257 3 8 "AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3

bind/dump/.gitkeep

Whitespace-only changes.

bind/master/external/example.com

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$ORIGIN example.com.
2+
$TTL 600
3+
@ IN SOA ns.example.com. noc.example.com. (
4+
1 ; serial
5+
10800 ; refresh (3 hours)
6+
600 ; retry (10 minutes)
7+
1209600 ; expire (2 weeks)
8+
3600 ) ; minimum (1 hour)
9+
@ IN NS ns.example.com.
10+
ns IN A 172.18.0.2
11+
www IN A 172.18.0.2

bind/master/internal/example.com

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$ORIGIN example.com.
2+
$TTL 600
3+
@ IN SOA ns.example.com. noc.example.com. (
4+
1 ; serial
5+
10800 ; refresh (3 hours)
6+
600 ; retry (10 minutes)
7+
1209600 ; expire (2 weeks)
8+
3600 ) ; minimum (1 hour)
9+
@ IN NS ns.example.com.
10+
ns IN A 127.0.0.1
11+
www IN A 127.0.0.1

0 commit comments

Comments
 (0)