Create containerized Core DNS server

domain.name.      IN  SOA dns.domain.name. domain.name.in. 2015082541 7200 3600 1209600 3600   
service-name IN A 10.10.x.x
service2 IN A 10.110.x.x
.:53 {   
forward . 164.100.3.1 # Gateway IP
log
errors
}

domain.name:53 {
file /root/domain.name.db
log
errors
}
docker run -d --name coredns -p 53:53/udp --restart=always \        --volume=/home/niccloud/coredns/:/root/ \ 
coredns:1.8.4 -conf /root/Corefile
ip a
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens3:
dhcp4: true
nameservers:
addresses:
- 10.10.x.x
ens4:
dhcp4: true
optional: true
version: 2
#!/bin/bash
##*********CREATE DIRECTORY***********
mkdir -p /home/coredns/
echo "Directory Successfully Created"
cd /home/coredns/
##************************************
echo
"domain.name. IN SOA dns.cloud.gov.in. pvtdns.domain.name. 2015082541 7200 3600 1209600 3600
service-name1 IN A 10.10.x.x
service2 IN A 10.10.x.x" >/home/coredns/domain.name.db
echo
".:53 {
forward . 164.100.3.1 # GATEWAy IP
log
errors
}
domain.name:53 {
file /root/domain.name.db
log
errors
} " > /home/coredns/Corefile
echo "Both files domain.name.db and Corefile is created successfully"
############ STOP Resolved Service If Running#######################
RESOLVE_SERVICE="systemd-resolve"
if pgrep -x "$RESOLVE_SERVICE" >/dev/null
then
echo "$RESOLVE_SERVICE is running So stopping the resolve service"
systemctl stop systemd-resolved
systemctl disable systemd-resolved
else
echo "$RESOLVE_SERVICE is not running so Start Docker."
fi
############*************************#########################

docker run -d --name coredns -p 53:53/udp --restart=always --volume=/home/coredns/:/root/ coredns:1.8.4 -conf /root/Corefile
docker ps | grep coredns
############***************************************

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store