When you use a VPS or dedicated server from DataPacket, you may want to control the DNS for your domains yourself. The most common software for this is called BIND.
First, install BIND. On Debian or Ubuntu, run apt install bind9 -y
. On CentOS, AlmaLinux, or Rocky Linux, run dnf install bind bind-utils -y
.
Next, make a zone file. A zone file is just a text file that tells the internet where to find your site. Here is an example you can copy, save it as /etc/bind/db.example.com
or /var/named/db.example.com
depending on your system:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2025090101 ; serial
3600 ; refresh
1800 ; retry
1209600 ; expire
86400 ) ; minimum
@ IN NS ns1.example.com.
@ IN NS ns2.example.com.
@ IN A 203.0.113.10
www IN A 203.0.113.10
ns1 IN A 203.0.113.10
ns2 IN A 203.0.113.10
Replace example.com
with your domain and replace 203.0.113.10
with your server’s IP address.
Now tell BIND to use the zone. On Debian or Ubuntu, edit /etc/bind/named.conf.local
. On CentOS or similar, edit /etc/named.conf
. Add this line:
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};
Restart BIND with systemctl restart bind9
on Debian or Ubuntu, or systemctl restart named
on CentOS, AlmaLinux or Rocky.
After this, go to your domain registrar and register two nameserver hostnames, like ns1.example.com
and ns2.example.com
, and point them to your server’s IP address. Then change your domain’s nameservers to use those new names.
That’s it. Your VPS or dedicated server is now serving DNS for your domain.