この章ではそれぞれの利用方法に対するガイドラインに沿った推奨設定について示します。 あるオプション設定については環境に応じた適切な値を設定することを推奨します。
以下の設定例はある会社の内部クライアントにのみサービスを提供するキャッシュ専用ネームサーバの一例です。 外部クライアントからの問い合わせはすべてallow-queryを使って拒否します。 同じことはそれに相当するファイアウォールのルールを設定することでも行えます。
// 問い合わせを許可したい2つの社内サブネット acl corpnets { 192.168.4.0/24; 192.168.7.0/24; }; options { // 作業ディレクトリ directory "/etc/namedb"; allow-query { corpnets; }; }; // ループバックアドレス 127.0.0.1 からの // 逆引き対応情報を提供 zone "0.0.127.in-addr.arpa" { type master; file "localhost.rev"; notify no; };
この設定例は、"example.com
"のマスターサーバとそのサブドメイン"eng.example.com
"のスレーブサーバの機能を提供する権威専用サーバの一例です。
options { // 作業ディレクトリ directory "/etc/namedb"; // キャッシュへのアクセスは許可しない allow-query-cache { none; }; // これはデフォルトの設定 allow-query { any; }; // 再帰問い合わせには対応しない recursion no; }; // ループバックアドレス 127.0.0.1 からの // 逆引き対応情報を提供 zone "0.0.127.in-addr.arpa" { type master; file "localhost.rev"; notify no; }; // このサーバは example.com のマスターサーバ zone "example.com" { type master; file "example.com.db"; // IP addresses of slave servers allowed to // transfer example.com allow-transfer { 192.168.4.14; 192.168.5.53; }; }; // このサーバは eng.example.com のスレーブサーバ zone "eng.example.com" { type slave; file "eng.example.com.bk"; // eng.example.com のマスターサーバのIPアドレス masters { 192.168.4.12; }; };
A primitive form of load balancing can be achieved in the DNS by using multiple records (such as multiple A records) for one name.
For example, if you have three WWW servers with network addresses of 10.0.0.1, 10.0.0.2 and 10.0.0.3, a set of records such as the following means that clients will connect to each machine one third of the time:
Name |
TTL |
CLASS |
TYPE |
Resource Record (RR) Data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
When a resolver queries for these records, BIND will rotate them and respond to the query with the records in a different order. In the example above, clients will randomly receive records in the order 1, 2, 3; 2, 3, 1; and 3, 1, 2. Most clients will use the first record returned and discard the rest.
For more detail on ordering responses, check the rrset-order sub-statement in the options statement, see RRset Ordering.
This section describes several indispensable diagnostic, administrative and monitoring tools available to the system administrator for controlling and debugging the name server daemon.
The dig, host, and nslookup programs are all command line tools for manually querying name servers. They differ in style and output format.
The domain information groper (dig) is the most versatile and complete of these lookup tools. It has two modes: simple interactive mode for a single query, and batch mode which executes a query for each in a list of several query lines. All query options are accessible from the command line.
dig
[@server
] domain
[query-type
] [query-class
] [+query-option
] [-dig-option
] [%comment
]
The usual simple use of dig will take the form
dig @server domain query-type query-class
For more information and a list of available commands and options, see the dig man page.
The host utility emphasizes simplicity and ease of use. By default, it converts between host names and Internet addresses, but its functionality can be extended with the use of options.
host
[-aCdlnrsTwv] [-c class
] [-N ndots
] [-t type
] [-W timeout
] [-R retries
] [-m flag
] [-4] [-6] hostname
[server
]
For more information and a list of available commands and options, see the host man page.
nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.
nslookup
[-option...] [[host-to-find
] | [- [server]]]
Interactive mode is entered when no arguments are given (the default name server will be used) or when the first argument is a hyphen (`-') and the second argument is the host name or Internet address of a name server.
Non-interactive mode is used when the name or Internet address of the host to be looked up is given as the first argument. The optional second argument specifies the host name or address of a name server.
Due to its arcane user interface and frequently inconsistent behavior, we do not recommend the use of nslookup. Use dig instead.
Administrative tools play an integral part in the management of a server.
The named-checkconf program
checks the syntax of a named.conf
file.
named-checkconf
[-jvz] [-t directory
] [filename
]
The named-checkzone program checks a master file for syntax and consistency.
named-checkzone
[-djqvD] [-c class
] [-o output
] [-t directory
] [-w directory
] [-k (ignore|warn|fail)
] [-n (ignore|warn|fail)
] [-W (ignore|warn)
] zone
[filename
]
Similar to named-checkzone, but it always dumps the zone content to a specified file (typically in a different format).
管理者は遠隔名前デーモン制御(rndc)プログラムを使ってネームサーバを制御することができます。 BIND 9.2から、rndcはndc startとndc restartを除いたすべてのBIND 8 ndcユーティリティのコマンドに対応するようになりました。なお、rndcはndcのチャンネルモードにも対応していません。 オプションを指定せずrndcを実行すると以下のような利用方法を出力します:
rndc
[-c 設定ファイル
] [-s サーバ
] [-p ポート番号
] [-y 鍵
] コマンド
[コマンド
...]
コマンドには以下のいずれか1つを指定します。
reload
設定ファイルとゾーンを再度読み込む。
reload zone
[class
[view
]]
指定されたゾーンを再度読み込む。
refresh zone
[class
[view
]]
Schedule zone maintenance for the given zone.
retransfer zone
[class
[view
]]
指定されたゾーンの情報を再度マスターサーバから転送する。
sign zone
[class
[view
]]
Fetch all DNSSEC keys for the given zone from the key directory (see key-directory in the section called “options Statement Definition and Usage”). If they are within their publication period, merge them into the zone's DNSKEY RRset. If the DNSKEY RRset is changed, then the zone is automatically re-signed with the new key set.
This command requires that the
auto-dnssec zone option be set
to allow
or
maintain
,
and also requires the zone to be configured to
allow dynamic DNS.
See the section called “Dynamic Update Policies” for
more details.
loadkeys zone
[class
[view
]]
Fetch all DNSSEC keys for the given zone from the key directory (see key-directory in the section called “options Statement Definition and Usage”). If they are within their publication period, merge them into the zone's DNSKEY RRset. Unlike rndc sign, however, the zone is not immediately re-signed by the new keys, but is allowed to incrementally re-sign over time.
This command requires that the
auto-dnssec zone option
be set to maintain
,
and also requires the zone to be configured to
allow dynamic DNS.
See the section called “Dynamic Update Policies” for
more details.
freeze
[zone
[class
[view
]]]
Suspend updates to a dynamic zone. If no zone is specified, then all zones are suspended. This allows manual edits to be made to a zone normally updated by dynamic update. It also causes changes in the journal file to be synced into the master and the journal file to be removed. All dynamic update attempts will be refused while the zone is frozen.
thaw
[zone
[class
[view
]]]
Enable updates to a frozen dynamic zone. If no zone is specified, then all frozen zones are enabled. This causes the server to reload the zone from disk, and re-enables dynamic updates after the load has completed. After a zone is thawed, dynamic updates will no longer be refused.
notify zone
[class
[view
]]
ゾーン通知メッセージを再送する
reconfig
Reload the configuration file and load new zones, but do not reload existing zone files even if they have changed. This is faster than a full reload when there is a large number of zones because it avoids the need to examine the modification times of the zones files.
stats
Write server statistics to the statistics file.
querylog
Toggle query logging. Query logging can also be enabled
by explicitly directing the queries
category to a
channel in the
logging section of
named.conf
or by specifying
querylog yes; in the
options section of
named.conf
.
dumpdb
[-all|-cache|-zone]
[view ...
]
Dump the server's caches (default) and/or zones to the dump file for the specified views. If no view is specified, all views are dumped.
secroots
[view ...
]
Dump the server's security roots to the secroots file for the specified views. If no view is specified, security roots for all views are dumped.
stop [-p]
Stop the server, making sure any recent changes
made through dynamic update or IXFR are first saved to
the master files of the updated zones.
If -p
is specified named's process id is returned.
This allows an external process to determine when named
had completed stopping.
halt [-p]
Stop the server immediately. Recent changes
made through dynamic update or IXFR are not saved to
the master files, but will be rolled forward from the
journal files when the server is restarted.
If -p
is specified named's process id is returned.
This allows an external process to determine when named
had completed halting.
trace
Increment the servers debugging level by one.
trace level
Sets the server's debugging level to an explicit value.
notrace
Sets the server's debugging level to 0.
flush
Flushes the server's cache.
flushname
name
Flushes the given name from the server's cache.
status
Display status of the server. Note that the number of zones includes the internal bind/CH zone and the default ./IN hint zone if there is not an explicit root zone configured.
recursing
Dump the list of queries named is currently recursing on.
validation
[on|off]
[view ...
]
Enable or disable DNSSEC validation.
Note dnssec-enable also needs to be
set to yes
to be effective.
It defaults to enabled.
tsig-list
List the names of all TSIG keys currently configured for use by named in each view. The list both statically configured keys and dynamic TKEY-negotiated keys.
tsig-delete
keyname
[view
]Delete a given TKEY-negotated key from the server. (This does not apply to statically configured TSIG keys.)
addzone
zone
[class
[view
]]
configuration
Add a zone while the server is running. This
command requires the
allow-new-zones option to be set
to yes
. The
configuration
string
specified on the command line is the zone
configuration text that would ordinarily be
placed in named.conf
.
The configuration is saved in a file called
,
where hash
.nzfhash
is a
cryptographic hash generated from the name of
the view. When named is
restarted, the file will be loaded into the view
configuration, so that zones that were added
can persist after a restart.
This sample addzone command
would add the zone example.com
to the default view:
$
rndc addzone example.com '{ type master; file "example.com.db"; };'
(Note the brackets and semi-colon around the zone configuration text.)
delzone
zone
[class
[view
]]
Delete a zone while the server is running. Only zones that were originally added via rndc addzone can be deleted in this matter.
A configuration file is required, since all
communication with the server is authenticated with
digital signatures that rely on a shared secret, and
there is no way to provide that secret other than with a
configuration file. The default location for the
rndc configuration file is
/etc/rndc.conf
, but an
alternate
location can be specified with the -c
option. If the configuration file is not found,
rndc will also look in
/etc/rndc.key
(or whatever
sysconfdir
was defined when
the BIND build was
configured).
The rndc.key
file is
generated by
running rndc-confgen -a as
described in
the section called “controls Statement Definition and
Usage”.
The format of the configuration file is similar to
that of named.conf
, but
limited to
only four statements, the options,
key, server and
include
statements. These statements are what associate the
secret keys to the servers with which they are meant to
be shared. The order of statements is not
significant.
The options statement has
three clauses:
default-server, default-key,
and default-port.
default-server takes a
host name or address argument and represents the server
that will
be contacted if no -s
option is provided on the command line.
default-key takes
the name of a key as its argument, as defined by a key statement.
default-port specifies the
port to which
rndc should connect if no
port is given on the command line or in a
server statement.
The key statement defines a
key to be used
by rndc when authenticating
with
named. Its syntax is
identical to the
key statement in named.conf
.
The keyword key
is
followed by a key name, which must be a valid
domain name, though it need not actually be hierarchical;
thus,
a string like "rndc_key
" is a valid
name.
The key statement has two
clauses:
algorithm and secret.
While the configuration parser will accept any string as the
argument
to algorithm, currently only the string "hmac-md5
"
has any meaning. The secret is a base-64 encoded string
as specified in RFC 3548.
The server statement
associates a key
defined using the key
statement with a server.
The keyword server
is followed by a
host name or address. The server statement
has two clauses: key and port.
The key clause specifies the
name of the key
to be used when communicating with this server, and the
port clause can be used to
specify the port rndc should
connect
to on the server.
A sample minimal configuration file is as follows:
key rndc_key { algorithm "hmac-md5"; secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K"; }; options { default-server 127.0.0.1; default-key rndc_key; };
This file, if installed as /etc/rndc.conf
,
would allow the command:
$
rndc reload
to connect to 127.0.0.1 port 953 and cause the name server to reload, if a name server on the local machine were running with following controls statements:
controls { inet 127.0.0.1 allow { localhost; } keys { rndc_key; }; };
and it had an identical key statement for
rndc_key
.
Running the rndc-confgen
program will
conveniently create a rndc.conf
file for you, and also display the
corresponding controls
statement that you need to
add to named.conf
.
Alternatively,
you can run rndc-confgen -a
to set up
a rndc.key
file and not
modify
named.conf
at all.
Certain UNIX signals cause the name server to take specific actions, as described in the following table. These signals can be sent using the kill command.
SIGHUP |
Causes the server to read |
SIGTERM |
Causes the server to clean up and exit. |
SIGINT |
Causes the server to clean up and exit. |