DNS (Domain Name System) plays a crucial role in mapping human-readable domain names into machine-friendly IP addresses, acting as a "phonebook" in the middle. Whether you're managing a private network or hosting web services, a reliable DNS solution ensures smooth communication and connectivity. The BIND (Berkeley Internet Name Domain) DNS server, one of the most widely used and trusted DNS software, offers a reliable infrastructure for creating and managing domain name resolution services. Its flexibility, scalability, and support for advanced configurations make it the go-to choice for administrators around the globe.
, which provides high-compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. It also offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider you choose and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit straight to your dashboard.
3) Click on Start to start creating your very first compute node.
2) Next, select a geographical region from the Region dropdown where you want to launch your VM (e.g., United States).
Step 4: Choose VM Configuration and Image
1) After selecting your required configuration options, you'll see the available VMs in your region and as per (or very close to) your configuration. In our case, we'll choose a '4 vCPUs/4GB/80GB SSD' Compute node.
2) Next, you'll need to choose an image for your Virtual Machine. For the scope of this tutorial, we'll select Ubuntu, as we will deploy the DNS server on Ubuntu 22.04.
2) Next, you'll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
That's it! You are now ready to deploy the node. Finalize the configuration summary; if it looks good, go ahead and click Create to deploy the node.
Step 8: Install BIND 9
1) Before moving to the installation of BIND 9, let's first update the package source list and upgrade the softwares
apt update -y && apt upgrade -y
Output:
3) Check if the BIND 9 service is running
systemctl status bind9
Step 9: Configure BIND DNS Server
We'll configure the BIND 9 DNS server with its two configuration files: named.conf.options, which is its main configuration file, and named.conf.local, which is used to define local DNS zones for a private domain.
1) Configure named.conf.options
a) Open the file with the Nano editor
sudo nano /etc/bind/named.conf.options
The file that opens up looks like this:
b) Edit the content of the file
(replace <YOUR_REVERSE_IP_NAME> with your reverse zone IP name)
zone "nodeshift.local" IN { //define forward zone
type master;
file "/etc/bind/zones/forward.nodeshift";
};
zone "<YOUR_REVERSE_IP_NAME>.in-addr.arpa" IN { // define reverse zone
type master;
file "/etc/bind/zones/reverse.nodeshift.rev";
};
c) Check the syntax
named-checkconf /etc/bind/named.conf.local
If it executes successfully without any errors/outputs, the syntax is correct.
Step 10: Configure the Zone files
Now, let's configure the zone files we defined in the previous step.
First, create a directory for zone files to save our files.
mkdir /etc/bind/zones
1) Create forward zone file
First, we'll create a forward zone file /etc/bind/zones/forward.nodeshift , which will be responsible for helping the BIND DNS server to resolve names (e.g., bindserver.nodeshift.local) to IP addresses (e.g., 192.168.2.2).
a) Copy the default db.local zone file to /etc/bind/zones/forward.nodeshift
cp /etc/bind/db.local /etc/bind/zones/forward.nodeshift
b) Open forward.nodeshift file in Nano editor
sudo nano /etc/bind/zones/forward.nodeshift
c) Make the necessary edits
$TTL 604800
; SOA record for forward.nodeshift zone
@ IN SOA nodeshift.local. root.nodeshift.local. (
1 ; Serial (increment after each change)
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; NS record pointing to the authoritative nameserver
@ IN NS bindserver.nodeshift.local.
; A record for name server
bindserver IN A 192.168.2.2
; A record for clients
client1 IN A 192.168.2.3
client2 IN A 192.168.2.4
the edited file looks something like this:
2) Configure the reverse zone file
Next, we'll create and configure the reverse zone file /etc/bind/zones/reverse.nodeshift.rev. It is responsible for helping the DNS server to resolve IP addresses -> Names (for e.g., 192.168.2.2 -> bindserver.nodeshift.local)
a) Copy the default db.local file to /etc/bind/zones/reverse.nodeshift.rev
cp /etc/bind/db.local /etc/bind/zones/reverse.nodeshift.rev
b) Edit the content of the file, according to the below instructions
(replace <YOUR_SERVER_IP> with your server's IP address)
$TTL 604800
; SOA record for reverse.nodeshift zone
@ IN SOA nodeshift.local. root.nodeshift.local. (
1 ; Serial (increment after each change)
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; NS record for reverse zone
@ IN NS bindserver.nodeshift.local.
; A record for name server
bindserver IN A <YOUR_SERVER_IP>
; PTR record for name server
2 IN PTR bindserver.nodeshift.local
; PTR record for clients
3 IN PTR client1.nodeshift.local
4 IN PTR client2.nodeshift.local
the file should look similar to this:
3) Restart BIND 9 server
Once you're done with the above zone files configurations, restart the server for changes to take effect.
systemctl restart bind9
Step 11: Configure Clients for using BIND DNS
Now, when our private BIND DNS is configured, let's configure clients to use the server.
1) Check the interface
(replace <YOUR_SERVER_IP> with your server's IP address)
ip -brief addr show to <YOUR_SERVER_IP>/24
Output:
b) Open the file (shown in the above output)
Come back to the root directory and open the YAML file using Nano
sudo nano /etc/netplan/50-cloud-init.yaml
c) Make the necessary edits as per the below template
network:
version: 2
ethernets:
enp0s5:
addresses:
- 192.168.2.3/24 # IP of client1
- 192.168.2.4/24 # IP of client2
match:
macaddress: ca:06:71:90:38:f9
mtu: 1500
nameservers:
addresses:
- 192.168.2.2 # Private DNS server IP
search: [ nodeshift.local ] # Domain name of your private DNS
set-name: enp0s5
this is how the edited file looks:
3) Test the configuration
Once the configuration is done, test it with the command below:
netplan try
It will ask you to accept the changes, press ENTER, and it's done!
nslookup client2
Output:
Conclusion
Setting up a private BIND DNS server is essential in managing domain name resolution for your internal network. In this tutorial, we’ve walked you through configuring BIND 9, forward and reverse zones, ensuring your private DNS is set up properly. By deploying this setup on NodeShift's cloud platform, we took advantage of a high-performance virtual machine, which simplified our deployment process and also provided a reliable foundation for deploying critical services like DNS servers.
For more information about NodeShift:
SOCIAL SHARE CARD GENERATOR