forked from pymumu/smartdns
-
Notifications
You must be signed in to change notification settings - Fork 11
在alpine linux上安装配置 smartdns 作为 doh\dot 服务器
PikuZheng edited this page Nov 11, 2024
·
1 revision
smartdns 作为 dot 服务器,需要 v41.0.12 或更高版本 smartdns 作为 doh 服务器,需要 v45.0.5 或更高版本
- 建立配置文件 /etc/smartdns/smartdns.conf :
bind-tls :853
bind-https :443
bind-cert-file /etc/smartdns/smartdns-cert.pem
bind-cert-key-file /etc/smartdns/smartdns-key.key
log-num 1
server-tls dns.google -subnet 140.238.42.0
speed-check-mode none
force-qtype-SOA 28 65
response-mode fastest-response
serve-expired no
dualstack-ip-selection no
其他配置取默认值。请按自己需要增减配置。
- 建立自动启动配置文件
/etc/init.d/smartdns
#!/sbin/openrc-run
depend() {
need net
}
start() {
ebegin "Starting smartdns"
/usr/sbin/smartdns -p /var/run/smartdns.pid /etc/smartdns/smartdns.conf
eend $?
}
stop() {
ebegin "Stopping smartdns"
pid="$(cat "/var/run/smartdns.pid" | head -n 1 2>/dev/null)"
if [ -z "$pid" ]; then
echo "smartdns not running."
exit 0
fi
kill -15 "$pid" 2>/dev/null
eend $?
}
- 下载 smartdns 运行时必要的文件并配置自动启动。目前(此 wiki 编辑时)最新版本是 v46.0.12
wget https://github.com/PikuZheng/smartdns/releases/download/1.2024.v46.0.12/smartdns-x86_64 -O /usr/sbin/smartdns
chmod +x /usr/sbin/smartdns
chmod +x /etc/init.d/smartdns
rc-update add smartdns
service smartdns start #立即启动
- 检查运行情况
netstat -tnlp | grep smartdns
如果正确显示了853端口监听,即为运行正常。