0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DNS、CDNサービスの詳細解説(五)

Last updated at Posted at 2025-04-08

DNS逆引きゾーンとスレーブサーバーの実装ガイド

1. 逆引きゾーンの設定

1.1 逆引きゾーン構成の基本

逆引きゾーンはIPアドレスからFQDNへの変換を可能にします。
ゾーン名の命名規則

ネットワークアドレスを逆順 + .in-addr.arpa.
例:10.0.0.0/24 → 0.0.10.in-addr.arpa.

1.2 主要設定手順

(1) ゾーン定義の追加

zone "0.0.10.in-addr.arpa" {
    type master;
    file "10.0.0.zone";
};

(2) ゾーンファイルの作成

$TTL 86400
$ORIGIN 0.0.10.in-addr.arpa.
@   IN  SOA  ns1.example.com. admin.example.com. (
    2023082101  ; Serial
    1H          ; Refresh
    5M          ; Retry
    7D          ; Expire
    1D )        ; Minimum

    NS  ns1.example.com.
100 PTR www.example.com.
200 PTR mail.example.com.

重要なポイント

  • PTRレコードのみを使用
  • ホスト部は最後のオクテットのみ記述
  • ORIGINディレクティブでベースドメインを定義

1.3 実践的な設定例

マスターサーバー側設定

# ゾーンファイルのコピー
cp -p /var/named/named.loopback /var/named/10.0.0.zone

# 構文チェック
named-checkzone 0.0.10.in-addr.arpa /var/named/10.0.0.zone

クライアント側検証コマンド

# 逆引きテスト
dig -x 10.0.0.100 @10.0.0.8

# 期待される出力
;; ANSWER SECTION:
100.0.0.10.in-addr.arpa. 86400 IN PTR www.example.com.

2. スレーブサーバーの実装

2.1 スレーブサーバーの要件

項目 要件
ネットワーク接続性 マスターサーバーと通信可能
タイム同期 NTPによる時刻同期必須
ソフトウェアバージョン BINDのバージョン一致推奨
ディレクトリ権限 /var/named/slaves 書き込み可能

2.2 マスターサーバー側設定

zone "example.com" {
    type master;
    file "example.com.zone";
    allow-transfer { 10.0.0.18; }; // スレーブのIPを許可
};

ゾーンファイルの必須項目

@    IN  NS  ns1.example.com.
     IN  NS  ns2.example.com.
ns2  IN  A   10.0.0.18

2.3 スレーブサーバー側設定

zone "example.com" {
    type slave;
    masters { 10.0.0.8; };
    file "slaves/example.com.slave";
};

自動生成ファイルの確認

ls -l /var/named/slaves/
total 4
-rw-r--r-- 1 named named 432 Aug 21 10:00 example.com.slave

2.4 ゾーン転送の検証

転送トリガー方法

# マスター側でシリアル番号更新
perl -pi -e 's/(\d+)(\s+;\s+Serial)/$1+1 . $2/e' /var/named/example.com.zone

# スレーブ側で強制転送
rndc retransfer example.com

転送状態の確認

# ログ確認
tail -f /var/log/named.log

3. フェイルオーバーの検証

3.1 テストシナリオ

  1. マスターサーバー停止
systemctl stop named
  1. クライアント側でのDNS問い合わせ
dig www.example.com @10.0.0.18

期待される動作

  • スレーブサーバーから正常に応答
  • TTL値がマスター設定を継承

3.2 自動フェイルバック

マスター復旧時:

systemctl start named

スレーブは自動的に最新データを同期

4. 高度な設定テクニック

4.1 複数スレーブの設定

// マスター設定
allow-transfer { 10.0.0.18; 10.0.0.28; };

4.2 TSIGによる安全なゾーン転送

# 鍵生成
dnssec-keygen -a HMAC-SHA512 -b 512 -n HOST example-transfer

# 設定ファイル追記
key "example-transfer" {
    algorithm hmac-sha512;
    secret "xxxxxxxxxxxxxxxxxxxx==";
};

5. トラブルシューティングガイド

5.1 よくある問題と解決策

現象 確認ポイント 解決方法
ゾーン転送が完了しない ファイアウォール設定(TCP 53) ポート開放
スレーブがデータを取得できない マスターのallow-transfer設定 ACLの再確認
逆引きが機能しない PTRレコードの記述形式 最後のオクテットのみを使用

5.2 有用なデバッグコマンド

# ゾーン転送の強制実行
rndc retransfer example.com

# 転送状態の詳細表示
named-checkzone -D example.com /var/named/slaves/example.com.slave

6. パフォーマンスチューニング

6.1 キャッシュ設定の最適化

options {
    max-transfer-time-in 60;
    transfers-in 10;
    transfers-per-ns 2;
};

6.2 スレッドプール設定

options {
    listen-on port 53 { any; };
    coresize default;
    max-cache-size 512M;
    recursive-clients 1000;
};
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?