这应该是最终的解决方法了
docker连接warp
我个人是使用的caomingjun/warp镜像来运行warp,如果大家有其他的镜像也可以切换
核心是要连接warp,并且将流量通过一个指定端口开放到本机
连接方法同 warp解决方法,此处不赘述
sing-box 配置
首先,就像之前那篇文章所说一样,如果不对sing-box进行修改,sing-box会影响warp的确认连接状态以及重新连接的请求,从而导致一打开sing-box,warp就会自动断连
因此,我们需要调整我们的sing-box配置,将指定的请求过滤掉
这部分我们能从cloudflare one的warp的官方文档中找到,我的warp是使用的MASQUE协议,所以根据文档中所显示,我需要将162.159.197.0/24 2606:4700:102::/48的443 500 1701 4500 4443 8443 8095端口使用本机流量代理
另外zero-trust-client.cloudflareclient.com 和 notifications.cloudflareclient.com域在之前我的运行中发现经常被访问,在文档中写了这两个域的用途,不过由于我的能力不足,所以没有很好的理解这两个域的作用
如果有人能和我解释一下的话,请务必评论
我在sing-box的配置文件中把这两个域也排除了,并且在使用过程中没有发现错误
以下是我目前的sing-box配置:
{ "log": { "level": "debug", "timestamp": true }, "dns": { "rules": [ { "rule_set": [ "geosite-cn" ], "server": "local" } ], "servers": [ { "type": "https", "server": "8.8.8.8", "detour": "warp-local", "tag": "remote" }, { "type": "hosts", "path": [], "predefined": {}, "tag": "host" }, { "type": "local", "tag": "local" } ], "strategy": "prefer_ipv4" }, "inbounds": [ { "interface_name": "sing-box-tun", "address": [ "172.20.0.1/30", "fdfe:dcba:9876::1/126" ], "route_address": [ "0.0.0.0/1", "128.0.0.0/1", "::/1", "8000::/1" ], "route_exclude_address": [ "192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12", "172.17.0.0/16", "172.19.0.0/12", "fc00::/7", "172.18.0.1/30", "162.159.197.0/24", "2606:4700:102::/48" ], "auto_route": true, "auto_redirect": true, "strict_route": true, "type": "tun" } ], "outbounds": [ { "type": "socks", "tag": "warp-local", "server": "127.0.0.1", "server_port": 1080, "udp_over_tcp": false }, { "type": "direct", "tag": "direct" } ], "route": { "final": "warp-local", "auto_detect_interface": true, "default_domain_resolver": "remote", "rules": [ { "action": "sniff" }, { "protocol": "dns", "action": "hijack-dns" }, { "domain": [ "zero-trust-client.cloudflareclient.com", "notifications.cloudflareclient.com" ], "outbound": "direct" }, { "rule_set": [ "geosite-cn", "geoip-cn" ], "outbound": "direct" }, { "ip_is_private": true, "outbound": "direct" }, { "process_path": [ "/usr/bin/cloudfalred" ], "outbound": "direct" } ], "rule_set": [ { "tag": "geoip-cn", "type": "remote", "format": "binary", "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", "download_detour": "warp-local" }, { "tag": "geosite-cn", "type": "remote", "format": "binary", "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", "download_detour": "warp-local" } ] }, "experimental": { "cache_file": { "enabled": true } }}启动顺序
使用docker和sing-box连接的时候,我们需要确定一点,就是我们必须要先打开docker,后打开sing-box
虽然原因我不太确定,但是如果先打开的sing-box,docker的warp-svc就不能够正常的打开,所以我们需要严格按照顺序启动
另外,对于linux来说,比较容易做到开机自动启动这两个服务,我们只需要先启动docker,然后利用timer任务,在5s后启动sing-box就可以了(一般来说,docker启动warp服务不需要5s),以下是我的timer任务文件内容
[Unit]Description=延迟启动sing-box (5 seconds after dependency starts)After=docker.service # 依赖的服务名
[Timer]OnActiveSec=5sUnit=sing-box.service
[Install]WantedBy=multi-user.target之后,我们只要关闭sing-box.service的自动启动,开启timer任务的自动启动,并且让timer任务拉起sing-box就好了
但是windows如何做到开机自动按顺序启动,并且还要有延迟,这就不是我所知道的了,还请各位各显神通
笔者随笔
另外,我个人使用的DNS是谷歌的DNS,也就是8.8.8.8,利用sing-box,我们还能利用DOH,我在使用火狐浏览器的时候,发现有些网站似乎需要DOH才能正常访问,这点我不太理解,知识不够,就不赘述了
但是总之,我的火狐浏览器的DNS是使用本机DNS,没有使用火狐自己的DNS保护,从而我能够正常访问大部分的网站
另外我在使用的过程中发现,warp在晚上的时候似乎速度会降低,在白天的时候速度最好,而我放弃代理模式的原因是:代理模式的速度明显比warp模式慢,所以我目前还是选择了使用warp模式 不过DNS并没有选择使用warp的DOH,而是使用sing-box劫持了DNS解析,使用google的DOH解析
部分信息可能已经过时









