基于 Apollo 的 SmartDNS 配置管理工具
go version >= 1.22
./build.sh
会生成 aarch64 x86 等平台的二进制程序
运行目录 /opt/cmclient
将对应平台的程序拷贝到运行目录,命名为 cmclient
拷贝 cmclient.yaml.demo 到运行目录,命名为 cmclient.yaml
拷贝 cmclient.service 到 /etc/systemd/system/
sudo systemctl daemon-reload
下面是 cmclient.yaml 的配置说明
configServer: http://192.168.74.40:8080 #Apollo Config Server 地址
appId: smartdns # Apollo Appid
cluster: beijing # Apollo 集群名称
accessKey: xxxx # Apollo 鉴权 AppKey
targetConfig: /etc/smartdns/conf.d/ # 将生成的配置存在哪里?
reloadCmd: /usr/bin/systemctl restart smartdns # 重启服务的命令
namespaces:
- service
- nameservers.txt
- rules.txt
- domains
根据 SmartDNS 文档进行安装
创建 /etc/smartdns/conf.d/ 目录
创建 smartdns.conf 内容如下
conf-file conf.d/*.conf
dualstack-ip-selection = yes
bind = :53
user = dns
speed-check-mode = ping,tcp:80,tcp:443
response-mode = fastest-ip
audit-enable = yes
audit-num = 16
audit-size = 16M
audit-file-mode = 0644
audit-file = /var/log/smartdns/smartdns-audit.log
log-level = error
log-num = 8
log-size = 2M
log-file-mode = 0644
log-file = /var/log/smartdns/smartdns.log
expand-ptr-from-address = yes
#reload = true
# nameservers
server tls://223.6.6.6
server tls://223.5.5.5
# rules
domain-rules /bj-home-ros-v6.ddns.hex.ac.cn/ -no-cache
domain-rules /hb-home-ros-ydv6.ddns.hex.ac.cn/ -no-cache
xxx.com = A,192.168.100.100
systemctl start cmclient.service # 启动
systemctl enable cmclient.service # 自启
journalctl -f -u cmclient # 日志