DNS 使用手册
使用举例
1、指定至少一个 DNS Server ;
2、开启 DNS Plugins ;
3、管理 cache 记录;
4、管理 cache 老化时间(只对动态添加的记录生效);
5、关闭 DNS Plugins。
# 指定 dns server
binary-api dns_name_server_add_del 114.114.114.114
# 开启 dns plugins
binary-api dns_enable_disable
# 查看 cache
show dns cache
# 添加 cache
dns cache add www.test.com 172.18.148.142
# 查看 cache 老化时间
show dns cache verbose
# 修改 cache 老化时间为24小时
dns set cache expiration time 84600
# 关闭 dns plugins
binary-api dns_enable_disable disable
接口解释
指定 DNS Server
# binary-api [help] <name> [<args>]
binary-api dns_name_server_add_del <ip-address> [del]
必选项, dns 服务器的 ip 地址。
[del]
条件可选项,如果是删除操作则必须加上。
查看 DNS Server
show dns servers
开启\关闭 DNS plugins
# binary-api [help] <name> [<args>]
binary-api dns_enable_disable [enable|disable]
[ enable | diable ]
可选项, enable 开启 DNS plugins , diable 关闭 DNS plugins 。如果没有添加该参数,命令默认添加 enable 参数。
查看 dns cache
show dns cache [verbose [n]]
[verbose [n]]
选填项, verbose 表示查看 dns 缓存的详细信息,不加 verbose 选项则仅显示 dns cache 总条数。
n 表示详细级别,默认为1,可以看到 dns 缓存配置,包括域名、 IP 、 TLL 、 在 UPF 中的时效等;级别2比级别1有更多的信息,从查询、回复和 dns 缓存当前状态三个维度展开;级别3可以看到客户端连接数等详细内容。
添加\删除 dns cache
注意,使用此命令手动添加 dns cache ,该条记录为静态 cache ,默认时效为24小时。
dns cache [add|del|clear] <name> [ip4|ip6]
[add|del|clear]
必填项, add 表示增加一条 dns 缓存, del 表示删除一条 dns 内容, clear 表示清空所有 dns 缓存。当操作为 add 或 del 时,需要带上 name 或 ip 的参数指明所要删除的 dns 缓存。
选填项,表示 dns 缓存的域名。
[ip4] [ip6]
选填项,表示 dns 缓存的 ip 。
设置非静态 cache 老化时间
dns set cache expiration time [seconds]
[seconds]
必填项,表示修改超时时间,以秒为单位。该设置对动态 cache 全局生效。
测试工具
1、格式化测试 dns 连接
该命令将发起一个样例 dns 请求及回复并打印出来。
test dns format [verbose [n]]
[verbose [n]]
选填项,参看
show dns cache [verbose [nn]]
中的解释。
2、反格式化测试 dns 连接
该命令将发起一个样例 dns 请求及回复并打印出来。
test dns unformat <name> [ip4|ip6]
必填项,域名
[ip4 | ip6]
必填项,域名对应的 IP 地址。
3、 dns 老化时间超时测试
该命令将设置有效时间为0,从而使 dns 缓存失效。
test dns expire <name>
必填项,指明要测试的域名。