This repository contains a Docker Compose setup for running a Bind9 DNS server, alongside the necessary DNS configuration files. It is designed to be easily customizable and deployable.
You can use this DNS for your home, so that you make your internet faster.
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved

docker-compose.yml
: Docker Compose file to set up the Bind9 DNS server.config/
: Directory containing configuration files for the DNS server.local-home.zone
: DNS zone file forlocal.home
. You can rename the file according to your need.named.conf
: Named configuration file for DNS server settings.sub-domain-com.zone
: DNS zone file forsub.domain.com
.
cache/
: Please create the folder in the same directory ofdocker-compose.yml
records/
: Please create the folder in the same directory ofdocker-compose.yml
pihole/
: Please create the folder in the same directory ofdocker-compose.yml
dnsmasq.d
: Please create the folder in the same directory ofdocker-compose.yml
-
Clone the Repository
Clone this repository to your local machine to get started.
git clone https://github.com/Anybody2007/bind9-and-pihole-docker.git
-
Configure DNS Records
Suggestion - It's better to avoid .local domain, because the internet does have this domain. So that means you will be forwarding your queries to the Root DNS for a local query.
Update the DNS records in
config/local-home.zone
andconfig/sub-domain-com.zone
as per your requirements.Change ROOT dns server as per your wish from the
docker-compose.yml
file. By changing theDNS1
andDNS2
, at your prefered DNS. -
Start Docker Compose
Run the following command in the root directory of this project:
docker-compose up -d
-
Docker Compose
The docker-compose.yml file sets up the Bind9 DNS server with the following specifications:
- Image: ubuntu/bind9:latest
- Ports: 53 (TCP and UDP)
- Volumes:
- Config directory mapped to
/etc/bind
- Cache directory mapped to
/var/cache/bind
- Records directory mapped to
/var/lib/bind
- Config directory mapped to
- Environment Variables:
BIND9_USER
: Set toroot
TZ
: Timezone set toAsia/Kolkata
-
DNS Zone Files
local-home.zone
- Defines the DNS settings for the local network domain local.home.
- Contains SOA, NS, and A records.
- The IP addresses should be updated according to your network setup.
sub-domain-com.zone
- Provides DNS settings for the external domain sub.domain.com.
- Has a structure similar to local-home.zone with customizable A records.
- This file is an example of how you can set up a zone for any domain you own.
-
Named Configuration (named.conf)
ACLs (Access Control Lists):
The configuration starts with defining ACLs to restrict DNS access. This is a crucial step to ensure that your DNS server is not used outside your intended network, enhancing security.
You need to provide your
IP/subnet
here. So that only your device can resolve the queries.eg -
192.168.0.1/24
or192.168.1.1/24
Forwarders:
- Forwarders are DNS servers to which queries are forwarded if the local server does not have the answer.
- In this setup, Cloudflare's malware protection DNS servers (
1.1.1.2
and1.0.0.2
) are used as forwarders. Feel free to substitute these with your preferred DNS servers.
Zone Configuration:
- Each domain managed by the DNS server has its own zone configuration.
- The
named.conf
file includes definitions for two zones:sub.domain.com:
A sample external domain. The corresponding zone file (sub-domain-com.zone
) includes the necessary DNS records for this domain.local.home:
A domain for the local network. Thelocal-home.zone
file outlines the DNS settings for devices and services within your local network.
- These zone files demonstrate how to configure DNS for both local and external domains, providing a template that can be adapted for other domains.
You can customize the DNS settings by editing the zone files and named.conf
as per your requirements. Make sure to update the IP addresses in the zone files to match your network configuration.