SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.18k stars 2.4k forks source link

DNS routing question #2089

Closed drno88 closed 2 months ago

drno88 commented 2 months ago

good day, please tell me, can I use my miniPC with Linux + singbox as a DNS server for my local network? I want it to respond with its IP, replacing DNS responses, and then route blocked resources to my remote vless server I want to get rid of the need to set up my miniPC as a gateway for clients on the network, I want to set it up as a DNS and route traffic based on it. Here is my current configuration

{ "log": { "level": "debug" }, "dns": { "servers": [ { "tag": "local-dns", "address": "local", "detour": "direct-out" }, { "tag": "cloudflare-dns", "address": "tls://1.1.1.1", "address_resolver": "local-dns", "detour": "xray-out" } ], "rules": [ { "outbound": "any", "server": "local-dns" }, { "rule_set": "antizapret", "server": "cloudflare-dns" } ] }, "inbounds": [ { "type": "mixed", "tag": "mixed-in", "listen": "0.0.0.0", "listen_port": 1080, "set_system_proxy": false, "sniff": true, "domain_strategy": "prefer_ipv4" }, { "type": "tun", "tag": "tun-in", "inet4_address": "172.19.16.1/30", "stack": "gvisor", "mtu": 9000, "auto_route": true, "strict_route": false, "endpoint_independent_nat": false, "sniff": true, "sniff_override_destination": true } ], "outbounds": [ { "type": "direct", "tag": "direct-out" }, { "type": "vless", "tag": "xray-out", "server": "185.174.137.226", "server_port": 443, "uuid": "3428e19b-d622-4958-a0ca-d89e834c4162", "flow": "xtls-rprx-vision", "network": "tcp", "tls": { "enabled": true, "server_name": "api.google.com", "reality": { "enabled": true, "public_key": "k1NbLDSAXJdSXTuQGQy62zewqw10Mz0taHX1GolSSX8", "short_id": "c8416f51" }, "utls": { "enabled": true, "fingerprint": "chrome" } }, "packet_encoding": "", "multiplex": {}, "transport": {} }, { "type": "dns", "tag": "dns-out" } ], "route": { "geosite": { "path": "geosite.db", "download_url": "https://github.com/yangchuansheng/sing-geosite/releases/latest/download/geosite.db", "download_detour": "direct-out" }, "geoip": { "path": "geoip.db", "download_url": "https://raw.githubusercontent.com/CHIZI-0618/v2ray-rules-dat/release/geoip.db", "download_detour": "direct-out" }, "rules": [ { "domain_suffix": ".developers.google.com", "outbound": "xray-out" }, { "domain_suffix": ".console.developers.google.com", "outbound": "xray-out" }, { "domain_suffix": ".speedtest.net", "outbound": "xray-out" }, { "geosite": [ "instagram", "youtube", "facebook", "twitter" ], "outbound": "xray-out" }, { "rule_set": "antizapret", "outbound": "xray-out" }, { "outbound": "direct-out" } ], "rule_set": [ { "type": "remote", "tag": "antizapret", "format": "binary", "url": "https://github.com/savely-krasovsky/antizapret-sing-box/releases/latest/download/antizapret.srs", "download_detour": "xray-out" } ], "auto_detect_interface": true }, "experimental": { "cache_file": { "enabled": true } } }

hengwu0 commented 2 months ago

Can I use my miniPC with Linux + singbox as a DNS server for my local network? A: yes, you can. but your configuration has something wrong. you can find manual here: https://sing-box.sagernet.org/configuration/dns/