この記事を作った動機
ある時、ChatGPT を使っていて、うまく設定が読み込めないという時があったときにそれについて調べてみたら、DNS 周りのキャッシュがおかしい説というのがあり、named のキャッシュを消そうとしてやり方がわからなかったので、自分用に記録するだけ。
設定する
少なくとも私の環境では、最初から rndc コマンドは使えるようになっておらず、設定が必要だった。rndc-confgen を使うことで、コンフィグは生成できるので、出てきたものをそれぞれ、named.conf と rndc.conf に貼り付ければとりあえずは動いた。
まだ設定がないときの rndc コマンドの挙動
sudo rndc status
# rndc: no server specified and no default
rndc status -s localhost
# rndc: no server specified and no default
rndc-confgen で設定を生成する
# sudo rndc-confgen
[sudo] share のパスワード:
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-sha256;
secret "secretString";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
# algorithm hmac-sha256;
# secret "secretString";
# };
#
# controls {
# inet 127.0.0.1 port 953
# allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf
設定を貼り付ける
/etc/rndc.conf (なければ作成する)
key "rndc-key" {
algorithm hmac-sha256;
secret "secretString";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
/etc/named.conf (追記する)
key "rndc-key" {
algorithm hmac-sha256;
secret "secretString";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
systemd で named を再起動する
sudo systemctl restart named
キャッシュを削除する
sudo rndc flush
参考にしたサイトとか
- rndc 鍵 (rndc.key) の作成 - hijiri-0404’s blog
https://hijiri0404.hatenablog.com/entry/2015/03/05/000245 (2025年10月2日) - domain name system - DNS on Redhat - rdnc: no server specified and no default - Server Fault
https://serverfault.com/questions/231749/dns-on-redhat-rdnc-no-server-specified-and-no-default (2025年10月2日) - BIND のキャッシュを消去する (CentOS 5.5): Linux の使い方
https://ez-net.jp/article/28/KPrxdINA/6oV8mNixA7et/ (2025年10月2日)