折腾了一堆nftables和iptables方法吧网络流量送到clash透明代理端口,偶然发现Clash.mate的tun模式实现了所有
笔者这里以树莓派5,Raspberry Pi OS 系统 (debian系) 进行部署
要实现完整的路由器功能,只需要配置一下 mihomo 的 tun 模式和自带的 dns 转发服务器即可,参考下面配置,tun 和 dns 块可以直接抄,除了代理节点、代理组、规则要自己写。
Linux 部署 mihomo 可以看我的另一篇教程:Linux 搭建 Clash WebUI(无桌面环境)|枯死的灌木
external-controller: '0.0.0.0:9090'
tun:
enable: true
stack: mixed
auto-route: true
auto-redirect: true
auto-detect-interface: true
dns-hijack:
- any:53
- tcp://any:53
device: mihomo
mtu: 9000
strict-route: false
gso: true
gso-max-size: 65536
udp-timeout: 300
iproute2-table-index: 2022
iproute2-rule-index: 9000
endpoint-independent-nat: false
route-exclude-address:
- 172.16.0.0/12
- 192.168.0.0/16
- fc00::/7
dns:
enable: true
listen: 0.0.0.0:53
ipv6: false
default-nameserver: [223.5.5.5, 119.29.29.29]
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
use-hosts: true
nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query']
fallback: ['https://doh.dns.sb/dns-query', 'https://dns.cloudflare.com/dns-query', 'https://dns.twnic.tw/dns-query', 'tls://8.8.4.4:853']
fallback-filter: { geoip: true, ipcidr: [240.0.0.0/4, 0.0.0.0/32] }
#代理节点
proxies:
#代理组
proxy-groups:
#路由规则
rules:
然后把其他设备的网关和 dns 指到刚才配置的 linux 主机即可
本站所有文章仅供学习了解,非盈利目的,请于下载后 24 小时内删除,不得用作任何商业用途。文字、数据及图片均有所属版权,如转载须注明来源。
务必循遵守所在地、所在国家和用户所在国家的法律法规,作者不对使用者任何不当行为负责。