Prerequisites
Before starting, ensure you have:
Server Requirements
- • RamNode VPS with at least 1GB RAM (2GB recommended for busy servers)
- • Ubuntu 22.04/24.04 or AlmaLinux 8/9
- • Root or sudo access
- • Static IP address (standard on RamNode VPS)
Additional Requirements
- • Domain name (for authoritative DNS)
- • SSH access credentials
- • Basic Linux command knowledge
- • Understanding of DNS concepts
Installation
Install BIND9 DNS server on your system:
apt update && apt install -y bind9 bind9-utils bind9-dnsutilsdnf install -y bind bind-utils✅ BIND9 is now installed and ready for configuration.
Directory Structure
Understanding BIND's layout helps with configuration and troubleshooting:
| Path | Description |
|---|---|
| /etc/bind/ | Ubuntu config directory |
| /etc/named/ | RHEL-based config directory |
| named.conf | Main configuration file |
| named.conf.options | Server options (Ubuntu) |
| named.conf.local | Zone definitions (Ubuntu) |
| zones/ | Zone files directory (create this) |
Option 1: Authoritative DNS Server
Option 2: Private Recursive Resolver
For a caching resolver serving your infrastructure:
ACL Configuration
acl "trusted" {
localhost;
10.0.0.0/8;
172.16.0.0/12;
192.168.0.0/16;
YOUR_TRUSTED_IPS;
};Options Configuration
options {
directory "/var/cache/bind";
recursion yes;
allow-recursion { trusted; };
allow-query { trusted; };
forwarders { 1.1.1.1; 1.0.0.1; 8.8.8.8; };
forward first;
dnssec-validation auto;
};⚠️ Important: Never enable open recursion on the internet. Always restrict recursive queries to trusted networks to prevent DNS amplification attacks.
Firewall Configuration
Configure your firewall to allow DNS traffic:
ufw allow 53/tcp
ufw allow 53/udp
ufw reloadfirewall-cmd --permanent --add-service=dns
firewall-cmd --reloadFor a private resolver, restrict source IPs:
ufw allow from YOUR_NETWORK/24 to any port 53Validation and Testing
Verify your configuration and test DNS resolution:
Check Configuration Syntax
named-checkconf
named-checkzone example.com /etc/bind/zones/db.example.comStart and Enable Service
systemctl enable --now namedsystemctl enable --now bind9Test DNS Resolution
dig @localhost example.com
dig @YOUR_VPS_IP example.com +short✅ If the dig commands return the expected records, your DNS server is working correctly.
Security Hardening
Zone Transfer Restrictions
Restrict zone transfers by specifying secondary servers explicitly:
allow-transfer { SECONDARY_IP; key "transfer-key"; };Response Rate Limiting
Enable response rate limiting (already included in the configuration above) to mitigate DNS amplification attacks.
Chroot Environment (RHEL)
dnf install bind-chroot
systemctl enable --now named-chrootFail2ban Integration
Create /etc/fail2ban/jail.d/named.conf:
[named-refused]
enabled = true
port = 53
filter = named-refused
logpath = /var/log/named/named.log
maxretry = 5
bantime = 3600Monitoring
Statistics Channel
Add to options block for statistics access:
statistics-channels {
inet 127.0.0.1 port 8053 allow { 127.0.0.1; };
};RNDC Commands
rndc status
rndc statsLog Rotation
Create /etc/logrotate.d/named:
/var/log/named/named.log {
weekly
rotate 4
compress
missingok
notifempty
postrotate
/usr/sbin/rndc reload > /dev/null 2>&1 || true
endscript
}Secondary DNS Setup
For redundancy, configure a second RamNode VPS as a secondary DNS server:
zone "example.com" {
type slave;
file "/var/cache/bind/db.example.com";
masters { PRIMARY_DNS_IP; };
};💡 Tip: For production authoritative DNS, run at least two geographically separated VPS instances as primary and secondary name servers.
Common Operations
Useful commands for managing your BIND server:
- •Reload after zone changes:
rndc reload - •Reload specific zone:
rndc reload example.com - •Clear cache (recursive resolver):
rndc flush
⚠️ Important: Always increment the serial number after every zone file edit—BIND won't propagate changes otherwise.
Troubleshooting
Check Logs
journalctl -u bind9 -f # Ubuntu
journalctl -u named -f # RHEL
tail -f /var/log/named/named.logCommon Issues
"zone has no NS records"
Ensure NS records point to valid hostnames with A records.
"network unreachable"
Check firewall rules and listen-on directives.
Changes not propagating
Verify serial number was incremented in the zone file.
Deployment Complete!
Your BIND DNS server is now deployed and ready to serve DNS queries. This setup provides a solid foundation for either authoritative DNS hosting or a private recursive resolver on your RamNode VPS.
