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サービスの詳細解説(八)

Posted at

インターネットDNSサービスアーキテクチャ構築ガイド

1. ネットワークトポロジー

1.1 ノード構成

役割 IPアドレス ホスト名例
クライアント 10.0.0.6/24 client.example
ローカルDNS(キャッシュ) 10.0.0.8/24 cache-dns.example
フォワードDNS 10.0.0.18/24 forward-dns.example
ルートDNS 10.0.0.28/24 root-dns.example
.org TLD DNS 10.0.0.38/24 org-tld.example
wang.org プライマリDNS 10.0.0.48/24 ns1.wang.org
wang.org セカンダリDNS 10.0.0.58/24 ns2.wang.org
Webサーバー 10.0.0.68/24 www.wang.org

2. 基本設定(全ノード共通)

2.1 初期設定

# SELinux無効化
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

# ファイアウォール設定
sudo systemctl stop firewalld
sudo systemctl disable firewalld

# 時刻同期
sudo yum install -y ntp
sudo systemctl enable --now ntpd

3. 各コンポーネントの詳細設定

3.1 Webサーバー設定(10.0.0.68)

sudo yum install -y httpd
echo "www.wang.org" | sudo tee /var/www/html/index.html
sudo systemctl enable --now httpd

3.2 wang.org プライマリDNS(10.0.0.48)

sudo yum install -y bind

# メイン設定
sudo tee /etc/named.conf <<'EOF'
options {
    directory "/var/named";
    listen-on port 53 { any; };
    allow-query     { any; };
    allow-transfer { 10.0.0.58; };
    recursion no;
    dnssec-enable no;
    dnssec-validation no;
};

zone "wang.org" IN {
    type master;
    file "wang.org.zone";
};
EOF

# ゾーンファイル作成
sudo tee /var/named/wang.org.zone <<'EOF'
$TTL 1D
@   IN SOA  ns1.wang.org. admin.wang.org. (
    2023082101 ; Serial
    3H         ; Refresh
    15M        ; Retry
    1W         ; Expire
    1D )       ; Minimum

    NS  ns1
    NS  ns2
ns1 A 10.0.0.48
ns2 A 10.0.0.58
www A 10.0.0.68
EOF

# サービス起動
sudo systemctl enable --now named

3.3 wang.org セカンダリDNS(10.0.0.58)

sudo yum install -y bind

# メイン設定
sudo tee /etc/named.conf <<'EOF'
options {
    directory "/var/named";
    listen-on port 53 { any; };
    allow-query     { any; };
    recursion no;
    dnssec-enable no;
    dnssec-validation no;
};

zone "wang.org" IN {
    type slave;
    masters { 10.0.0.48; };
    file "slaves/wang.org.zone";
};
EOF

# サービス起動
sudo systemctl enable --now named

3.4 .org TLD DNS(10.0.0.38)

sudo yum install -y bind

# メイン設定
sudo tee /etc/named.conf <<'EOF'
options {
    directory "/var/named";
    listen-on port 53 { any; };
    allow-query     { any; };
    recursion no;
    dnssec-enable no;
    dnssec-validation no;
};

zone "org" IN {
    type master;
    file "org.zone";
};
EOF

# ゾーンファイル作成
sudo tee /var/named/org.zone <<'EOF'
$TTL 1D
@   IN SOA  ns1.org. admin.org. (
    2023082101 ; Serial
    3H         ; Refresh
    15M        ; Retry
    1W         ; Expire
    1D )       ; Minimum

    NS  ns1
    NS  ns2
ns1 A 10.0.0.38
wang NS ns1.wang.org.
wang NS ns2.wang.org.
EOF

# サービス起動
sudo systemctl enable --now named

3.5 ルートDNS(10.0.0.28)

sudo yum install -y bind

# メイン設定
sudo tee /etc/named.conf <<'EOF'
options {
    directory "/var/named";
    listen-on port 53 { any; };
    allow-query     { any; };
    recursion no;
    dnssec-enable no;
    dnssec-validation no;
};

zone "." IN {
    type master;
    file "root.zone";
};
EOF

# ルートゾーンファイル作成
sudo tee /var/named/root.zone <<'EOF'
$TTL 1D
@   IN SOA  a.root-servers.net. admin.root. (
    2023082101 ; Serial
    3H         ; Refresh
    15M        ; Retry
    1W         ; Expire
    1D )       ; Minimum

    NS  a.root-servers.net.
a.root-servers.net. A 10.0.0.28
org. NS ns1.org.
ns1.org. A 10.0.0.38
EOF

# サービス起動
sudo systemctl enable --now named

4. 動作検証

4.1 クライアント側検証

# DNS設定確認
cat /etc/resolv.conf
# nameserver 10.0.0.8 を確認

# DNS解決テスト
dig @10.0.0.8 www.wang.org +trace
# 最終的に10.0.0.68を返答

# Webアクセス確認
curl http://www.wang.org
# "www.wang.org" が表示されることを確認

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

5.1 主要チェックポイント

# ゾーンファイル検証
sudo named-checkzone wang.org /var/named/wang.org.zone

# DNSキャッシュ確認
sudo rndc dumpdb -cache
sudo grep 'www.wang.org' /var/named/data/cache_dump.db

# パケットキャプチャ
sudo tcpdump -i any port 53 -n -v

6. セキュリティ強化(オプション)

6.1 TSIG鍵によるゾーン転送

# 鍵生成
sudo dnssec-keygen -a HMAC-SHA512 -b 512 -n HOST zone-xfer

# 設定反映
sudo tee -a /etc/named.conf <<'EOF'
key "zone-xfer" {
    algorithm hmac-sha512;
    secret "生成されたシークレットキー";
};
EOF

6.2 DNSSEC有効化

sudo dnssec-keygen -a RSASHA256 -b 2048 -n ZONE wang.org
sudo dnssec-signzone -A -3 $(head -c 1000 /dev/random | sha1sum | cut -b 1-16) -N INCREMENT -o wang.org -t wang.org.zone
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?