スプリットDNS設定手順
はじめに
1台のサーバで、要求元に応じて異なる検索結果を返す構成をスプリットDNSと呼びます。
同じネームスペースでも、内向きと外向きとでゾーンファイルを分けることで、内部のゾーン情報を第3者から隠すことができます。
bind 8とbind 9では以下の方法でスプリットDNSを実現します。
bind 8
- namedを2つ起動
- listen-on オプションでリスンするソケット(IPアドレス)を分ける
- ndc をリスンするソケットも分ける
- 待ち受けポートは53から変更できないため2つのnamed 起動時に "address already in use" が出力
bind 9
- view ステートメントで一つのnamed デーモンに集約できる
bind 9 ではview が導入され、スプリットDNSをシンプルに設定することができます。
ここでは、bind 9 でview による設定方法を説明します。
設定
view の構文
view "view_name" [class] { [ match-clients { address_match_list } ; ] [ match-destinations { address_match_list } ; ] [ match-recursive-only { yes | no } ; ] // view statements // zone clauses };
view_name は任意の名前となり、合致させたい要求元(match-client)もしくは
要求先(match-destination)を該当のview 内に記述します。
named が応答を返す際、各view 内の要求元(match-client)もしくは要求先(match-destination)に
最初に合致したview を使用します。
ドメインの構成
外向きの "external" view にはグローバルIP(10.0.0.0/8を想定)を持つホストを登録します。
view 名称 | 要求元 | recursion |
---|---|---|
internal | 192.168.1.0/24 | yes |
external | any | no |
設定内容
■named.conf
注意が必要なのは、最初に合致したmatch-client/match-destination が適用されるため、 internal をexternal より先に定義します。
acl local { 192.168.1.0/24; }; options { directory "/var/named"; pid-file "/var/named/named.pid"; }; view "internal" {<--- 内向き用 match-clients {<--- このview に合致する要求元 127.0.0.0/8; local; }; recursion yes;<--- 再起的な問い合わせ有効 zone "." { type hint; file "root.cache"; }; zone "localhost" { type master; file "localhost.zone"; }; zone "0.0.127.in-addr.arpa" { type master; file "localhost.rev"; }; zone "example.co.jp" { type master; file "example-internal.zone"; }; zone "1.168.192.in-addr.arpa" { type master; file "example.rev"; }; }; view "external" {<--- 外向き用 match-clients { any; };<--- 不特定の外部 recursion no;<--- 再起的な問い合わせ無効 zone "." { type hint; file "root.cache"; }; zone "localhost" { type master; file "localhost.zone"; }; zone "example.co.jp" { type master; file "example-external.zone"; }; zone "10.in-addr.arpa" { type master; file "example-external.rev"; }; };
view の構成要素
view を構成するステートメント構文を以下に示します。
options 内に記述するステートメントは基本的に view の中に記述できます。
ステートメント | 記述先 |
---|---|
allow-transfer { address_list; } | [ Opt, View, Zone ] |
allow-query { address_list; } | [ Opt, View, Zone ] |
allow-recursion { address_list; } | [ Opt, View ] |
directory "directory"; | [ Opt ] |
match-clients { address_list; } | [ view ] |
match-destinations { address_list; } | [ view ] |
recursion ( yes | no ); | [ Opt, View ] |