#!/bin/sh
#
# chkconfig: 345 55 45
# description: BIND 9.2.3rc3
# probe: true
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/local/sbin/named ] || exit 0
[ -f /etc/named.conf ] || exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting named: "
daemon /usr/local/sbin/named -u named
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
echo
;;
stop)
# Stop daemons.
echo -n "Shutting down named: "
killproc named
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
echo
;;
status)
/usr/local/sbin/rndc status
exit $?
;;
restart)
$0 stop
$0 start
;;
reload)
/usr/local/sbin/rndc reload
exit $?
;;
probe)
# named knows how to reload intelligently; we don't want linuxconf
# to offer to restart every time
/usr/local/sbin/rndc reload >/dev/null 2>&1 || echo start
exit 0
;;
*)
echo "Usage: named {start|stop|status|restart}"
exit 1
esac
exit $RETVAL
|
options {
directory "/var/named";
pid-file "named.pid"; // デフォルトだと /var/run/named.pid でエラーになるので指定する
// (-u で named になるが、/var/run は root しか書けない)
forwarders { 192.168.10.10; }; // 親DNSのアドレス
allow-recursion { 127.0.0.1; }; // ローカルクエリだけを再帰解決する
auth-nxdomain no ;
// query-source address * port 53;
root-delegation-only ; // こうすると "delegation-only" を個々に指定しなくても良い
// root-delegation-only exclude { "de"; "lv"; "museum"; }; // 除外を指定するにはこう書きます
};
zone "." {
// ルートDNSのヒントファイル
type hint;
file "named.root"; // Internic からもらってくる
};
zone "com" { // これを記述しないと NXDOMAIN が返ってこない (root-delegation-only があればほぼ不要)
type delegation-only ;
};
zone "net" {
type delegation-only ;
};
zone "cc" {
type delegation-only ;
};
zone "0.0.127.in-addr.arpa" {
// 127.0.0.1 を解決するファイル
type master;
file "named.local";
};
zone "example.com" {
// 自ドメインの正引き情報
type master;
file "example.com";
allow-transfer { 192.168.11.10; }; // セカンダリDNSにのみドメインテーブル転送を許可する
};
zone "second.com" {
// セカンダリの正引き情報 (セカンダリを請け負う場合)
type slave;
file "slave/second.com";
masters { 192.168.200.20; }; // セカンダリを依頼されたサーバ (プライマリのこと)
allow-transfer { none ; } ;
};
|
Internic で配布しているのでここに記述しません |
@ 86400 IN SOA localhost. postmaster.localhost. (
2001010101 ; Serial number
3H ; Refresh after 3 hours
1H ; Retry after 1 hours
1W ; Expire after 1 week
1D ) ; Minimum TTL of 1 day
$TTL 1D
IN NS localhost.
1 IN PTR localhost.
|
@ 86400 IN SOA dns.example.com. postmaster.dns.example.com. (
2001010101 ; Serial number
3H ; Refresh after 3 hours
1H ; Retry after 1 hours
1W ; Expire after 1 week
1D ) ; Minimum TTL of 1 day
$TTL 1D
IN MX 10 mail.example.com. ; ドメインメールサーバ
IN NS dns.example.com.
IN NS dns2.example.com. ; セカンダリDNS
IN A 192.168.1.1 ; 自分のアドレス
localhost IN A 127.0.0.1
www IN A 192.168.1.2 ; Webサーバのアドレス
cname IN CNAME www.example.com. ; Webサーバの別名 (バーチャル Web 用)
|
BIND が自動生成します |
nameserver 127.0.0.1 |