這是本文件的舊版!


BIND

install

pkg install bind911 sysrc named_enable=“YES”

generate key (note that the service start will do that)

rndc-confgen -a

check config

named-checkconf
named-checkzone localhost /var/named/<filename>

set directory

options {
        // All file and path names are relative to the chroot directory,
        // if any, and should be fully qualified.
        directory       "/usr/local/etc/namedb";
        ...
}

debug config

logging {
    channel default-log {
        file "/var/log/named.log" versions 10 size 200m;
        severity info;
        print-severity  yes;
        print-time yes;
    };
    category lame-servers { default-log; };
    category security{ default-log;};
    category queries { default-log;};
    category default { default-log;};
};

zone

zone "example.org" {
        type master;
        file "master/example.org";
};

zone file

$TTL 3600        ; 1 hour default TTL
example.org.    IN      SOA      ns1.example.org. admin.example.org. (
                                2017010301      ; Serial
                                10800           ; Refresh
                                3600            ; Retry
                                604800          ; Expire
                                300             ; Negative Response TTL
                        )

; DNS Servers
                IN      NS      ns1.example.org.

; MX Records
                IN      MX 10   mx.example.org.
                IN      MX 20   mail.example.org.

; Machine Names
@               IN      A       192.168.1.1
ns1             IN      A       192.168.1.2
mail            IN      A       192.168.1.3

; Aliases
www             IN      CNAME   example.org.

reverse zone file

@       IN      SOA     example.org. admin.example.org. (
                              2017010301      ; serial
                              14400           ; refresh
                              3600            ; retry
                              604800          ; expire
                              10800           ; minimum
)
 
1.168.192.in-addr.arpa.      IN      NS      ns1.example.org.
2                            IN      PTR     ns1.example.org.
3                            IN      PTR     mail.example.org.

bind 安全設定