CoreDNS is a flexible DNS server that can be used as an alternative to traditional DNS servers such as BIND or NSD. In this tutorial, we will guide you through the installation of CoreDNS on Debian Latest.
Before starting with the installation, make sure you have the following prerequisites:
Before installing CoreDNS, it's a good practice to update the system with the latest patches and security updates. You can do this by running the following command:
sudo apt-get update && sudo apt-get upgrade -y
You can install CoreDNS using the Debian package manager (apt). To do this, follow these steps:
First, add the CoreDNS repository to your Debian system. To do this, create a new file named coredns.list
in the /etc/apt/sources.list.d/
directory:
sudo nano /etc/apt/sources.list.d/coredns.list
Add the following line to the file:
deb https://packagecloud.io/coredns/coredns/debian/ stretch main
Save and exit the file.
Download and add the GPG key for the CoreDNS repository:
curl -L https://packagecloud.io/coredns/coredns/gpgkey | sudo apt-key add -
Update the package list:
sudo apt-get update
Install CoreDNS:
sudo apt-get install coredns -y
Wait for the installation to complete.
After installing CoreDNS, you need to configure it to work properly. By default, CoreDNS listens on the port 53. You can change this by editing the CoreDNS configuration file.
Open the Corefile
configuration file in a text editor:
sudo nano /etc/coredns/Corefile
Edit the file to define the DNS zones that CoreDNS will manage. For example, to define a zone for example.com
, add the following lines:
example.com {
file /etc/coredns/example.com.db
}
Save and exit the file.
Create a forward zone file for the example.com
domain:
sudo nano /etc/coredns/example.com.db
Add the following example contents to the file:
$ORIGIN example.com.
$TTL 86400
example.com. IN SOA ns1.example.com. hostmaster.example.com. (
2022010100 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)
example.com. IN NS ns1.example.com.
ns1 IN A 192.168.1.1
www IN A 192.168.1.2
Save and exit the file.
Restart CoreDNS to apply the changes:
sudo systemctl restart coredns
You have successfully installed and configured CoreDNS on Debian Latest. You can now use CoreDNS as an alternative to traditional DNS servers. Remember to update the DNS records when necessary and make backups of the configuration files.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!