mirror of
https://github.com/andrey271192/Keenetic-Split-DNS.git
synced 2026-09-20 11:55:36 +00:00
Initial release: install, uninstall, SmartDNS, web UI
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
41
etc/config.yaml.example
Normal file
41
etc/config.yaml.example
Normal 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"
|
||||
19
etc/domain-sets/ru-services.txt
Normal file
19
etc/domain-sets/ru-services.txt
Normal 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
|
||||
29
etc/lighttpd/lighttpd.conf
Normal file
29
etc/lighttpd/lighttpd.conf
Normal 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
|
||||
34
etc/ndm/netfilter.d/010-keenetic-split-dns.sh
Executable file
34
etc/ndm/netfilter.d/010-keenetic-split-dns.sh
Executable 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
|
||||
12
etc/smartdns/smartdns.conf.head
Normal file
12
etc/smartdns/smartdns.conf.head
Normal 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
|
||||
Reference in New Issue
Block a user