山东协和学院2016年护士资格证领取时间及地点
Install BIND using the package manager (apt for Ubuntu/Debian, dnf for CentOS/RHEL). 2. Configure global options in named.conf.options or named.conf to allow queries, set forwarders (like 8.8.8.8), enable recursion, and listen on all interfaces. 3. Set up a forward zone by adding a zone entry in named.conf.local (Ubuntu) or named.conf (CentOS) and create a zone file (e.g., db.example.local) with SOA, NS, and A records mapping hostnames to IPs. 4. Optionally, configure a reverse zone for PTR records by defining the reverse zone in the config and creating a corresponding reverse zone file (e.g., db.192.168.1). 5. Test configuration syntax with named-checkconf and validate zone files with named-checkzone, then restart the BIND service (bind9 on Ubuntu, named on CentOS) and enable it at boot. 6. Test DNS resolution using dig or nslookup for both forward and reverse lookups, and update client DNS settings to point to the new server; ensure zone serials are incremented on changes and use rndc reload to apply updates without full restart, while securing the server against open resolution and monitoring logs appropriately.
Setting up a DNS server on Linux using BIND (Berkeley Internet Name Domain) is a common task for managing internal network resolution or hosting domain names. BIND is the most widely used DNS software on Unix-like systems. Here’s how to set it up step by step on a typical Linux distribution like Ubuntu or CentOS.

1. Install BIND
First, install the BIND package using your distribution’s package manager.
On Ubuntu/Debian:

sudo apt update sudo apt install bind9 bind9utils bind9-doc
On CentOS/RHEL/Rocky Linux:
sudo dnf install bind bind-utils -y
After installation, the main configuration files are usually located in /etc/bind/
(Debian/Ubuntu) or /etc/named.conf
(RHEL-based).

2. Configure the Main BIND File (named.conf.options
)
Edit the global options file to define how your DNS server behaves.
On Ubuntu:
sudo nano /etc/bind/named.conf.options
On CentOS:
sudo nano /etc/named.conf
Add or modify the options
block to allow queries and set forwarders (e.g., Google’s DNS):
options { directory "/var/cache/bind"; // Allow queries from your local network allow-query { localhost; 192.168.1.0/24; }; // Forward DNS queries to external servers forwarders { 8.8.8.8; 8.8.4.4; }; // Enable recursion recursion yes; // Disable DNSSEC for simplicity (optional) dnssec-validation no; // Listen on all interfaces listen-on-v6 { any; }; listen-on { any; }; };
Replace
192.168.1.0/24
with your actual network subnet.
3. Set Up a Forward Zone (Domain to IP)
This allows your DNS server to resolve a domain name (e.g., example.local
) to an internal IP.
a. Add Zone in named.conf.local
(Ubuntu) or named.conf
(CentOS)
On Ubuntu:
sudo nano /etc/bind/named.conf.local
Add:
zone "example.local" { type master; file "/etc/bind/db.example.local"; };
On CentOS:
Add the same block in /etc/named.conf
inside the appropriate section.
b. Create the Zone File
Copy the default zone template:
sudo cp /etc/bind/db.local /etc/bind/db.example.local
Edit the new file:
sudo nano /etc/bind/db.example.local
Update it like this:
$TTL 604800 @ IN SOA ns1.example.local. admin.example.local. ( 3 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns1.example.local. @ IN A 192.168.1.10 ns1 IN A 192.168.1.10 www IN A 192.168.1.20 mail IN A 192.168.1.30
- Replace IPs as needed.
- The
@
represents the domain itself. - The email
admin.example.local.
corresponds toadmin@example.local
(note the trailing dot).
4. (Optional) Set Up a Reverse Zone (IP to Domain)
This allows reverse DNS lookups (PTR records).
a. Add Reverse Zone
In named.conf.local
(Ubuntu) or named.conf
(CentOS):
zone "1.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192.168.1"; };
b. Create Reverse Zone File
sudo cp /etc/bind/db.127 /etc/bind/db.192.168.1 sudo nano /etc/bind/db.192.168.1
Edit:
$TTL 604800 @ IN SOA ns1.example.local. admin.example.local. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns1.example.local. 10 IN PTR ns1.example.local. 20 IN PTR www.example.local. 30 IN PTR mail.example.local.
This maps IPs like 192.168.1.10
→ ns1.example.local
.
5. Test Configuration and Restart BIND
Check for syntax errors:
sudo named-checkconf
Check zone files:
sudo named-checkzone example.local /etc/bind/db.example.local sudo named-checkzone 1.168.192.in-addr.arpa /etc/bind/db.192.168.1
If all is good, restart BIND:
Ubuntu:
sudo systemctl restart bind9
CentOS:
sudo systemctl restart named
Enable on boot:
sudo systemctl enable bind9 # or named
6. Test the DNS Server
Use dig
or nslookup
to verify:
dig @localhost example.local dig @localhost www.example.local dig -x 192.168.1.20
You should see correct A or PTR records.
Also, update your client machines to use this server as their DNS (e.g., set DNS to 192.168.1.10
in network settings).
Final Notes
- Keep serial numbers updated (increment them) when changing zone files.
- Use
rndc reload
to reload zones without restarting:sudo rndc reload example.local
- Secure your DNS server: avoid open resolvers, use ACLs, and monitor logs in
/var/log/syslog
or/var/log/messages
.
Basically, that’s it — you now have a working authoritative and recursive DNS server using BIND on Linux. It’s not complicated, but attention to syntax and permissions matters.
The above is the detailed content of How to Set Up a DNS Server on Linux Using BIND. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and
