متقدم
البحث فيأدلة التثبيت
طريقة البحث
  • الصق رسالة الخطأ بين علامتي تنصيص، مثل "permission denied"، لتجد جدول الحل.
  • اختر مجالًا وجزءًا من الدليل (التثبيت، أول الإعدادات، الاستخدام اليومي، الأمان، الحلول) لتصل مباشرة إلى الخطوة الصحيحة.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

الدليل 76BIND DNS · Network

Install and set up BIND (DNS server)

BIND (named) is the classic DNS server. Companies use it in two roles: as an authoritative server for their own zones (example.com, internal corp.example.com, reverse zones), and as a recursive resolver with caching for their networks. This guide installs BIND on RHEL and Ubuntu, sets up a safe resolver, creates a forward and a reverse zone, adds a secondary server with a TSIG key, and covers the checks and fixes every DNS admin needs.

  • 11 الدروس
  • 10 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

76.1

Know it before you install

An authoritative server answers for zones it owns (from zone files). A recursive server finds answers for anyone's names on the internet and caches them. Keep the two roles apart on internet-facing servers — an open resolver is abused for DDoS attacks.

ItemRHEL / Rocky / AlmaUbuntu / Debian
Packagesbind, bind-utilsbind9, bind9-utils, bind9-dnsutils
Servicenamed.servicenamed.service (bind9 is an alias)
Main config/etc/named.conf/etc/bind/named.conf (+ named.conf.options, named.conf.local)
Zone files/var/named//etc/bind/ or /var/lib/bind/
Toolsnamed-checkconf, named-checkzone, rndc, digthe same
Ports53/udp and 53/tcpthe same

الأوامر في هذا الدرس

76.2

Install on RHEL, Rocky, Alma and Fedora

dnf -y install bind bind-utils
systemctl enable --now named
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload

76.3

Install on Ubuntu and Debian

apt-get update
apt-get install -y bind9 bind9-utils bind9-dnsutils
systemctl enable --now named
ufw allow 53

انتبه

On Ubuntu, systemd-resolved listens on 127.0.0.53:53. That is fine for BIND on the server's own IPs; if you need BIND on 127.0.0.1 too, set DNSStubListener=no in /etc/systemd/resolved.conf and restart systemd-resolved.

الأوامر في هذا الدرس

76.4

First configuration: a safe resolver

Recursion only for your networks, DNSSEC validation on, version hidden (RHEL: in /etc/named.conf; Ubuntu: in named.conf.options):

/etc/named.conf (options part)
acl "trusted" {
    127.0.0.1;
    10.0.0.0/8;
    192.168.0.0/16;
};
 
options {
    directory "/var/named";
    listen-on port 53 { 127.0.0.1; 10.0.0.53; };
    listen-on-v6 port 53 { ::1; };
    allow-query { trusted; };
    allow-recursion { trusted; };
    allow-transfer { none; };
    recursion yes;
    dnssec-validation auto;
    version "not available";
    forwarders { 1.1.1.1; 9.9.9.9; };
    forward first;
};
SettingWhy
allow-recursion { trusted; }Only your networks may use the resolver — no open resolver.
allow-transfer { none; }Nobody can download your zones, except secondaries you allow per zone.
dnssec-validation autoReject forged answers for signed zones.
listen-onOnly the IPs that should answer.
forwarders (optional)Send queries to upstream resolvers; without it BIND resolves from the root servers itself.
named-checkconf
systemctl reload named
dig @10.0.0.53 www.redhat.com +short

76.5

An authoritative zone

Add the zones to the config (RHEL: /etc/named.conf; Ubuntu: named.conf.local):

/etc/named.conf (zones)
zone "corp.example.com" IN {
    type primary;
    file "corp.example.com.zone";
    allow-transfer { key "xfer-key"; };
    notify yes;
};
 
zone "1.0.10.in-addr.arpa" IN {
    type primary;
    file "10.0.1.rev";
};
/var/named/corp.example.com.zone
$TTL 3600
@       IN  SOA ns1.corp.example.com. hostmaster.corp.example.com. (
            2026111701 ; serial YYYYMMDDNN
            3600       ; refresh
            900        ; retry
            1209600    ; expire
            300 )      ; negative cache TTL
        IN  NS   ns1.corp.example.com.
        IN  NS   ns2.corp.example.com.
        IN  MX   10 mail.corp.example.com.
ns1     IN  A    10.0.0.53
ns2     IN  A    10.0.0.54
web1    IN  A    10.0.1.11
db1     IN  A    10.0.1.21
mail    IN  A    10.0.1.25
www     IN  CNAME web1
/var/named/10.0.1.rev
$TTL 3600
@   IN  SOA ns1.corp.example.com. hostmaster.corp.example.com. ( 2026111701 3600 900 1209600 300 )
    IN  NS  ns1.corp.example.com.
11  IN  PTR web1.corp.example.com.
21  IN  PTR db1.corp.example.com.

Check, fix rights and SELinux (RHEL), reload:

named-checkzone corp.example.com /var/named/corp.example.com.zone
zone corp.example.com/IN: loaded serial 2026111701
OK
named-checkzone 1.0.10.in-addr.arpa /var/named/10.0.1.rev
chown root:named /var/named/*.zone /var/named/*.rev
restorecon -Rv /var/named
rndc reload
dig @10.0.0.53 web1.corp.example.com +short
10.0.1.11
dig @10.0.0.53 -x 10.0.1.11 +short
web1.corp.example.com.

تذكّر

Increase the serial at every change of a zone file, or the secondaries will not take the change.

76.6

A secondary server with TSIG

Make a shared key on the primary, copy the same key block to the secondary:

tsig-keygen -a hmac-sha256 xfer-key > /etc/named/xfer-key.conf
chown root:named /etc/named/xfer-key.conf && chmod 640 /etc/named/xfer-key.conf

Include it on both servers (include "/etc/named/xfer-key.conf";). On the secondary:

/etc/named.conf (secondary)
server 10.0.0.53 { keys { xfer-key; }; };
 
zone "corp.example.com" IN {
    type secondary;
    primaries { 10.0.0.53 key xfer-key; };
    file "slaves/corp.example.com.zone";
};

76.7

Daily use: the commands and the real uses

rndc status
rndc reload corp.example.com
rndc flush
rndc dumpdb -cache
rndc querylog on
journalctl -u named -f
dig @10.0.0.53 corp.example.com SOA +short
dig @10.0.0.53 corp.example.com AXFR
dig +trace www.example.org

Real uses at work:

  • Internal DNS for servers and apps (corp.example.com), with reverse zones for logs and tools.
  • A caching resolver for offices and data centers (with DNSSEC validation).
  • Split DNS (different answers inside and outside) with view blocks.

76.8

Make it safe

Security checklist:

  • No open resolver: allow-recursion only for trusted networks.
  • allow-transfer only with TSIG keys to your secondaries.
  • dnssec-validation auto; sign your public zones (DNSSEC) when possible.
  • Run authoritative and recursive roles on different servers for internet-facing DNS.
  • Keep BIND updated (security releases are frequent); hide the version; rate limiting (rate-limit block) on authoritative servers.
  • Zone files and keys with tight rights; SELinux on.

76.9

Update and remove

dnf -y upgrade bind bind-utils
apt-get install --only-upgrade -y bind9
named-checkconf && systemctl restart named
dnf -y remove bind

76.10

Fix common problems

ProblemCauseFix
status: REFUSEDThe client is not in allow-query/allow-recursion.Add its network to the trusted ACL.
status: SERVFAIL for external namesDNSSEC validation failed, no internet/forwarders, or wrong time.Check time (chrony); dig +cd to test without validation; check forwarders.
Zone does not loadSyntax error, missing dot at the end of a name, wrong file rights.named-checkzone; journalctl -u named; owner root:named, restorecon.
Secondary keeps the old dataSerial not increased.Increase the serial; rndc reload; check notify.
Names resolve to web1.corp.example.com.corp.example.comMissing trailing dot on a full name.Write full names with a . at the end.
BIND will not start on Ubuntu: port in usesystemd-resolved stub listener.Listen on specific IPs, or DNSStubListener=no.

76.11

Next steps

1Why must allow-recursion be limited to your own networks?

An open resolver is used by attackers for DNS amplification DDoS attacks.

2You changed a zone file, but the secondary still shows the old IP. Why?

The SOA serial was not increased, so the secondary did not transfer the zone.

كل الأوامر في هذا الفصل