サービス管理
CoreDNS の状態を確認します:
systemctl status coredns
CoreDNS を再起動:
systemctl restart coredns
CoreDNS をリロードします:
systemctl reload coredns
CoreDNS を停止:
systemctl stop coredns
CoreDNS を起動します:
systemctl start coredns
CoreDNS のログを表示:
journalctl -u coredns -f
DNS の設定
CoreDNS の主要な設定ファイルは次のとおりです:
/etc/coredns/Corefile
既定の設定では DNS クエリを次に転送します:
1.1.1.1 8.8.8.8
Corefile は、具体的な要件とユースケースに合わせて設定してください。
Corefile を変更したら CoreDNS を再起動します:
systemctl restart coredns
DNS エンドポイント
- DNS:
53/tcpと53/udp - ヘルス:
http://127.0.0.1:8080/health - Ready:
http://127.0.0.1:8181/ready - メトリクス:
http://127.0.0.1:9153/metrics
重要なファイルとディレクトリ
- バイナリ:
/usr/bin/coredns - Corefile:
/etc/coredns/Corefile - サービス:
/etc/systemd/system/coredns.service - Sysusers:
/usr/lib/sysusers.d/coredns.conf - Tmpfiles:
/usr/lib/tmpfiles.d/coredns.conf - Logrotate:
/etc/logrotate.d/coredns - データディレクトリ:
/var/lib/coredns - ログファイル:
/var/log/coredns.log - エラーログ:
/var/log/coredns.err.log - リゾルバーの上書き:
/etc/systemd/resolved.conf.d/99-coredns.conf
DNS 解決のテスト
CoreDNS に直接問い合わせます:
dig @127.0.0.1 example.com
あるいはサーバーの IP アドレスで問い合わせます:
dig @<SERVER-IP> example.com
The host's /etc/resolv.conf is configured to use:
nameserver 127.0.0.1
注意事項
- CoreDNS uses
systemd-resolvedポート 53 を解放するための設定変更を行います。 - The host resolver is pointed to
127.0.0.1. - DNS クエリは、設定された上流リゾルバーへ転送されます。
- CoreDNS runs under the dedicated
corednssystem user.