# create Dockerfile
FROM alpine:latest
RUN apk add --no-cache bind
RUN cp /etc/bind/named.conf.authoritative /etc/bind/named.conf
RUN sed -i "s/127.0.0.1/any/g" /etc/bind/named.conf
EXPOSE 53/tcp
EXPOSE 53/udp
CMD ["named", "-c", "/etc/bind/named.conf", "-g", "-u", "named"]
# build image
docker buildx build -t bind9-alpine:latest .
# save image
docker save bind9-alpine:latest > bind9-alpine.tar
# upload image to mikrotik
echo 'put bind9-alpine.tar' | sftp user@mikrotik
---
mikrotik
/container config
set registry-url=https://registry-1.docker.io
/interface bridge
add name=Docker
/ip address
add address=10.0.0.1/24 interface=Docker
/ip firewall nat
add chain=srcnat src-address=10.0.0.0/24 action=masquerade
/interface veth
add address=10.0.0.10/24 gateway=10.0.0.1 name=veth-bind9
/interface bridge port
add bridge=Docker interface=veth-bind9
/container mounts
add name=bind9 src=/bind9 dst=/etc/bind/
/container
add interface=veth-bind9 file=bind9-alpine.tar mounts=bind9 logging=yes
#start container (check container number with command print)
start 0
# shell to container number 0
shell 0
# append zone config to /etc/bind/named.conf
cat >> /etc/bind/named.conf << 'EOF'
zone "domain.tld" IN {
type master;
file "/etc/bind/zone/db.domain.tld";
};
EOF
# create zone file db.domain.tld
cat > /etc/bind/zone/db.domain.tld << 'EOF'
$TTL 3600
$ORIGIN domain.tld.
@ SOA ns1.domain.tld. dns.domain.tld. (
2023102100 ; Serial
28800 ; Refresh
7200 ; Retry
604800 ; Expire
7200 ) ; Minimum
NS ns1.domain.tld.
MX 10 mail.thnic.co.th.
A 10.0.0.10
www A 10.0.0.10
ns1 A 10.0.0.10
EOF
# reconfig bind
rndc reconfig