https://onitroad.com 更多教程

rndc 命令示例

键入 rndc 以显示该实用程序的用法和可用命令列表:

# rndc
Usage: rndc [-b address] [-c config] [-s server] [-p port]
        [-k key-file ] [-y key] [-V] command
command is one of the following:
  reload        Reload configuration file and zones.
  reload zone [class [view]]
                Reload a single zone.
  refresh zone [class [view]]
                Schedule immediate maintenance for a zone.
  retransfer zone [class [view]]
                Retransfer a single zone without checking the serial number.
  freeze        Suspend updates to all dynamic zones.
  freeze zone [class [view]]
                Suspend updates to a dynamic zone.
  thaw          Enable updates to all dynamic zones and reload them.
  thaw zone [class [view]]
                Enable updates to a frozen dynamic zone and reload it.
  sync [-clean] Dump changes to all dynamic zones to disk, and optionally
  ....

以下是一些 rndc 命令的示例:

  1. 使用rndc status命令查看named服务的当前状态:
# rndc status
number of zones: 3
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/1000
tcp clients: 0/100
server is up and running

使用 rndc reload 命令重新加载配置文件和区域:

# rndc reload
server reload successful
如何使用 rndc 命令(named 的命令行管理工具)

rndc 实用程序是一个命令行工具,用于在本地和远程计算机上管理命名服务。
为了防止对服务的未授权访问,必须将 rndc 配置为侦听所选端口(默认为 953 端口),并且服务和 rndc 实用程序必须使用相同的密钥。
rndc 密钥是通过使用以下命令生成的:

# rndc-confgen -a
wrote key file "/etc/rndc.key"

此命令创建 /etc/rndc.key 文件,其中包含密钥。

# cat /etc/rndc.key
key "rndc-key" {
        algorithm hmac-md5;
        secret "k7WFNCP01e1NwIgaIhvtQQ==";
};

要将 named 配置为使用密钥,请在 /etc/named.conf 中包含以下条目:

# vi /etc/named.conf<
include “/etc/rndc.key”;
controls {
         inet 127.0.0.1 allow { localhost; } keys { “rndckey”; }
};

include 语句允许包含文件,以便可以将潜在的敏感数据放置在具有受限权限的单独文件中。
要确保只有 root 可以读取该文件,请输入以下内容:

# chmod o-rwx /etc/rndc.key

控制语句定义了使用 rndc 命令所需的访问信息和各种安全要求。

  • inet :该示例允许我们从本地主机 (127.0.0.1) 上的控制台控制 rndc。
  • keys:keys密钥用于验证各种操作,是远程管理的主要访问控制方法。该示例指定使用 rndckey,它在 /etc/rndc.key 包含文件中定义。
日期:2020-09-17 00:13:58 来源:oir作者:oir