差異處
這裏顯示兩個版本的差異處。
| Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
|
bind [2017/01/03 22:11] 127.0.0.1 |
bind [2017/01/10 22:47] (目前版本) jz |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | BIND | + | ====== BIND ====== |
| - | + | ||
| - | ====== install ====== | + | |
| + | ==== Install ==== | ||
| + | <code> | ||
| pkg install bind911 | pkg install bind911 | ||
| sysrc named_enable="YES" | sysrc named_enable="YES" | ||
| + | </code> | ||
| - | # generate key (note that the service start will do that) | + | ==== Generate key (note that the service start will do that) ==== |
| + | <code> | ||
| rndc-confgen -a | rndc-confgen -a | ||
| + | </code> | ||
| - | ===== check config ===== | + | ==== Check config ==== |
| + | <code> | ||
| named-checkconf | named-checkconf | ||
| + | named-checkzone localhost /var/named/<filename> | ||
| + | </code> | ||
| - | ==== set directory ==== | + | ==== Set directory ==== |
| + | ''/usr/local/etc/namedb/named.conf'' | ||
| <code> | <code> | ||
| options { | options { | ||
| - | // All file and path names are relative to the chroot directory, | + | ... |
| - | // if any, and should be fully qualified. | + | |
| directory "/usr/local/etc/namedb"; | directory "/usr/local/etc/namedb"; | ||
| ... | ... | ||
| 行 22: | 行 28: | ||
| </code> | </code> | ||
| - | === debug config === | + | ==== Logging config for debug ==== |
| + | create log file manually | ||
| + | |||
| + | <code bash> | ||
| + | touch /var/log/named.log | ||
| + | chown bind:bind /var/log/named.log | ||
| + | </code> | ||
| + | |||
| + | ''/usr/local/etc/namedb/named.conf'' | ||
| <code> | <code> | ||
| logging { | logging { | ||
| 行 28: | 行 42: | ||
| file "/var/log/named.log" versions 10 size 200m; | file "/var/log/named.log" versions 10 size 200m; | ||
| severity info; | severity info; | ||
| + | print-category yes; | ||
| print-severity yes; | print-severity yes; | ||
| print-time yes; | print-time yes; | ||
| 行 38: | 行 53: | ||
| </code> | </code> | ||
| - | # zone | + | ==== Zone config ==== |
| + | ''/usr/local/etc/namedb/named.conf'' | ||
| <code> | <code> | ||
| zone "example.org" { | zone "example.org" { | ||
| 行 44: | 行 60: | ||
| file "master/example.org"; | file "master/example.org"; | ||
| }; | }; | ||
| - | </code> | ||
| - | == zone file == | + | zone "1.168.192.in-addr.arpa" { |
| + | type master; | ||
| + | file "master/1.168.192.in-addr.arpa"; | ||
| + | }; | ||
| + | </code> | ||
| + | ==== Zone file ==== | ||
| + | ''/usr/local/etc/namedb/master/example.org'' | ||
| <code> | <code> | ||
| $TTL 3600 ; 1 hour default TTL | $TTL 3600 ; 1 hour default TTL | ||
| example.org. IN SOA ns1.example.org. admin.example.org. ( | example.org. IN SOA ns1.example.org. admin.example.org. ( | ||
| - | 2006051501 ; Serial | + | 2017010301 ; Serial |
| 10800 ; Refresh | 10800 ; Refresh | ||
| 3600 ; Retry | 3600 ; Retry | ||
| 行 60: | 行 81: | ||
| ; DNS Servers | ; DNS Servers | ||
| IN NS ns1.example.org. | IN NS ns1.example.org. | ||
| - | IN NS ns2.example.org. | ||
| ; MX Records | ; MX Records | ||
| IN MX 10 mx.example.org. | IN MX 10 mx.example.org. | ||
| IN MX 20 mail.example.org. | IN MX 20 mail.example.org. | ||
| - | |||
| - | IN A 192.168.1.1 | ||
| ; Machine Names | ; Machine Names | ||
| - | localhost IN A 127.0.0.1 | + | @ IN A 192.168.1.1 |
| ns1 IN A 192.168.1.2 | ns1 IN A 192.168.1.2 | ||
| - | ns2 IN A 192.168.1.3 | + | mail IN A 192.168.1.3 |
| - | mx IN A 192.168.1.4 | + | |
| - | mail IN A 192.168.1.5 | + | |
| ; Aliases | ; Aliases | ||
| www IN CNAME example.org. | www IN CNAME example.org. | ||
| </code> | </code> | ||
| + | |||
| + | ==== reverse zone file ==== | ||
| + | ''/usr/local/etc/namedb/master/1.168.192.in-addr.arpa'' | ||
| + | <code> | ||
| + | @ 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. | ||
| + | </code> | ||
| + | |||
| + | ==== Start service ==== | ||
| + | <code bash> | ||
| + | service named start | ||
| + | </code> | ||
| + | |||
| + | |||
| + | [[http://wiki.weithenn.org/cgi-bin/wiki.pl?bind9-%E6%8F%90%E4%BE%9BDomain_Name%E8%88%87IP%E5%B0%8D%E6%87%89%E7%9A%84%E6%9C%8D%E5%8B%99|bind 安全設定]] | ||
