Skip to content
Home ยป Setting Up BIND Database Files

Setting Up BIND Database Files

Setting Up BIND Database Files (DNS Zone Files)


1. Introduction

In a DNS server using BIND (Berkeley Internet Name Domain), database files (zone files) store all the DNS records for a domain.
These files define how domain names are mapped to IP addresses and services.

๐Ÿ‘‰ In simple words:
Zone files = Database of DNS records


2. What is a Zone File?

A zone file is a text file that contains:

  • Domain information
  • DNS record types (A, MX, CNAME, etc.)
  • Mapping rules

๐Ÿ“Œ Each domain has at least:

  • Forward lookup zone
  • Reverse lookup zone

3. Location of BIND Zone Files

SystemLocation
Ubuntu/Debian/etc/bind/
RHEL/CentOS/var/named/

4. Types of Zone Files

1. Forward Zone File

  • Maps domain โ†’ IP address

2. Reverse Zone File

  • Maps IP address โ†’ domain

5. Defining Zone in BIND Configuration

Edit:

/etc/bind/named.conf.local

Forward Zone

zone "example.com" {
    type master;
    file "/etc/bind/db.example.com";
};

Reverse Zone

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192";
};

6. Creating Forward Zone File

Copy default template:

cp /etc/bind/db.local /etc/bind/db.example.com

Edit file:

vi /etc/bind/db.example.com

Example Forward Zone File

$TTL 604800
@   IN  SOA example.com. root.example.com. (
        2         ; Serial
        604800    ; Refresh
        86400     ; Retry
        2419200   ; Expire
        604800 )  ; Negative Cache TTL

@   IN  NS  ns.example.com.

@   IN  A   192.168.1.10
ns  IN  A   192.168.1.10
www IN  A   192.168.1.20
mail IN  A   192.168.1.30

@   IN  MX  10 mail.example.com.

7. Explanation of Zone File Entries

1. $TTL

  • Default time-to-live for records

2. SOA Record

@ IN SOA example.com. root.example.com.
  • Start of Authority
  • Contains admin and timing info

3. NS Record

@ IN NS ns.example.com.
  • Defines DNS server

4. A Record

www IN A 192.168.1.20
  • Maps domain โ†’ IP

5. MX Record

@ IN MX 10 mail.example.com.
  • Mail server definition

8. Creating Reverse Zone File

cp /etc/bind/db.127 /etc/bind/db.192
vi /etc/bind/db.192

Example Reverse Zone File

$TTL 604800
@   IN  SOA example.com. root.example.com. (
        2
        604800
        86400
        2419200
        604800 )

@   IN  NS  ns.example.com.

10  IN PTR example.com.
20  IN PTR www.example.com.
30  IN PTR mail.example.com.

9. Checking Configuration

Check Syntax

named-checkconf
named-checkzone example.com /etc/bind/db.example.com

10. Restart BIND Service

systemctl restart bind9

11. Testing DNS Setup

dig example.com
nslookup www.example.com

12. Important Points (Exam Focus)

  • Always end domain names with . in zone files
  • Increment serial number after changes
  • Maintain correct file permissions
  • Ensure correct IP mapping

13. Common Errors

  • Missing dot (.) at end of domain
  • Incorrect serial number
  • Wrong file path
  • Syntax errors in zone file

14. Conclusion

Setting up BIND database files is a crucial step in DNS configuration. Properly structured zone files ensure accurate name resolution, email routing, and service mapping, making them essential for network and server administration.