Initial release: install, uninstall, SmartDNS, web UI

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Андрей Бобырев
2026-05-24 22:15:37 +03:00
commit bc9355fe40
21 changed files with 2715 additions and 0 deletions

41
etc/config.yaml.example Normal file
View File

@@ -0,0 +1,41 @@
# Keenetic-Split-DNS — основной конфиг
# Копируется в /opt/etc/keenetic-split-dns/config.yaml при установке
version: 1
# IP роутера в LAN (веб-интерфейс и listen DNS)
lan_ip: "192.168.1.1"
web_port: 3200
# SmartDNS: порт DNS (53 при opkg dns-override, иначе 6053)
dns_port: 53
dns_listen: "0.0.0.0"
log_queries: true
cache_ttl_max: 3600
# Upstream по умолчанию для всех остальных доменов
default_upstream: isp-default
upstreams:
yandex-dot:
name: "Yandex DNS (DoT)"
type: dot
address: "77.88.8.8"
port: 853
sni: "common.dot.dns.yandex.net"
timeout: 5
isp-default:
name: "ISP / Keenetic DNS"
type: udp
# auto — detect-lan.sh / ndm: DNS провайдера или 127.0.0.1@53
address: "auto"
port: 53
timeout: 3
domain_groups:
ru-services:
name: "RU-сервисы (Yandex, VK, Mail, OK)"
upstream: yandex-dot
domain_set: "ru-services.txt"

View File

@@ -0,0 +1,19 @@
yandex.ru
ya.ru
yandex.com
yandex.net
yastatic.net
yandex.st
mail.ru
mail.com
imgsmail.ru
mycdn.me
vk.com
vk.me
vkuservideo.net
vkuseraudio.net
userapi.com
vk-cdn.net
ok.ru
odnoklassniki.ru
okcdn.ru

View File

@@ -0,0 +1,29 @@
# Keenetic-Split-DNS web UI — lighttpd
# Installed to /opt/etc/keenetic-split-dns/lighttpd.conf
server.document-root = "/opt/share/keenetic-split-dns/www"
server.port = 3200
server.bind = "LAN_IP_PLACEHOLDER"
server.errorlog = "/opt/var/log/keenetic-split-dns/lighttpd-error.log"
server.pid-file = "/opt/var/run/keenetic-split-dns/lighttpd.pid"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".css" => "text/css",
".js" => "application/javascript",
".json" => "application/json",
".svg" => "image/svg+xml",
".ico" => "image/x-icon"
)
cgi.assign = (
".cgi" => ""
)
url.rewrite-once = (
"^/api/?$" => "/api.cgi/status",
"^/api/(.*)$" => "/api.cgi/$1"
)
# LAN only — bind set at install/apply from config.yaml

View File

@@ -0,0 +1,34 @@
#!/bin/sh
# Keenetic-Split-DNS — redirect LAN DNS to SmartDNS (fallback if dns-override unavailable)
# Installed to /opt/etc/ndm/netfilter.d/010-keenetic-split-dns.sh
KSD_ETC="/opt/etc/keenetic-split-dns"
DNS_PORT="53"
[ -f "$KSD_ETC/config.yaml" ] || exit 0
# Skip if Entware dns-override is active
if [ -f /opt/etc/dns-override.conf ] && grep -q '^enabled=1' /opt/etc/dns-override.conf 2>/dev/null; then
exit 0
fi
LAN_IP="$(grep '^lan_ip:' "$KSD_ETC/config.yaml" 2>/dev/null | sed 's/.*"\([^"]*\)".*/\1/')"
[ -n "$LAN_IP" ] || LAN_IP="192.168.1.1"
DNS_PORT="$(grep '^dns_port:' "$KSD_ETC/config.yaml" 2>/dev/null | awk '{print $2}')"
[ -n "$DNS_PORT" ] || DNS_PORT="53"
case "$1" in
start|restart)
iptables -t nat -C PREROUTING -i br0 -p udp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT" 2>/dev/null \
|| iptables -t nat -A PREROUTING -i br0 -p udp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT"
iptables -t nat -C PREROUTING -i br0 -p tcp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT" 2>/dev/null \
|| iptables -t nat -A PREROUTING -i br0 -p tcp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT"
;;
stop)
iptables -t nat -D PREROUTING -i br0 -p udp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT" 2>/dev/null || true
iptables -t nat -D PREROUTING -i br0 -p tcp --dport 53 ! -d "$LAN_IP" -j REDIRECT --to-port "$DNS_PORT" 2>/dev/null || true
;;
esac
exit 0

View File

@@ -0,0 +1,12 @@
# Generated by Keenetic-Split-DNS — do not edit manually
# Source: /opt/etc/keenetic-split-dns/config.yaml
server-name keenetic-split-dns
log-level info
cache-size 512
cache-persist yes
prefetch-domain yes
serve-expired yes
dnsmasq-lease-file /var/lib/misc/dnsmasq.leases
# User settings appended by compile-config.sh