Xray 透明代理, 本机正常, 但是如果在 docker 内访问 mirror.ccs.tencentyun.com, 已经被识别为国内流量, 最后却提示 rcode: 3 错误.
我是在一台 Arch Linux 本机实作透明代理, 目前, 本机运行正常, 本机访问 https://mirrors.cloud.tencent.com/alpine/v3.19/main 是没问题的, 但是容器域名无法正常访问.
请看下面当运行 docker build 时候的日志. 明明已经被识别为国内的流量, 但是返回域名却为空, 并最后报 failed to lookup ip for domain mirror.ccs.tencentyun.com at server UDP:114.114.114.114:53 > rcode: 3 错误.
2024/02/27 01:19:07 [Debug] transport/internet/udp: UDP original destination: udp:192.168.21.1:53
2024/02/27 01:19:07 [Debug] transport/internet/udp: UDP original destination: udp:192.168.21.1:53
2024/02/27 01:19:07 [Debug] [2592277922] proxy/dokodemo: processing connection from: 192.168.21.100:56787
2024/02/27 01:19:07 [Info] [2592277922] proxy/dokodemo: received request for 192.168.21.100:56787
2024/02/27 01:19:07 [Debug] [4184404354] proxy/dokodemo: processing connection from: 192.168.21.100:63905
2024/02/27 01:19:07 [Info] [4184404354] proxy/dokodemo: received request for 192.168.21.100:63905
2024/02/27 01:19:07 192.168.21.100:56787 accepted udp:192.168.21.1:53 [transparent -> dns-outbound]
2024/02/27 01:19:07 192.168.21.100:63905 accepted udp:192.168.21.1:53 [transparent -> dns-outbound]
2024/02/27 01:19:07 [Info] [2592277922] app/dispatcher: taking detour [dns-outbound] for [udp:192.168.21.1:53]
2024/02/27 01:19:07 [Info] [2592277922] proxy/dns: handling DNS traffic to udp:192.168.21.1:53
2024/02/27 01:19:07 [Info] [4184404354] app/dispatcher: taking detour [dns-outbound] for [udp:192.168.21.1:53]
2024/02/27 01:19:07 [Info] [4184404354] proxy/dns: handling DNS traffic to udp:192.168.21.1:53
2024/02/27 01:19:07 [Debug] app/dns: domain mirror.ccs.tencentyun.com matches following rules: [geosite:cn(DNS idx:0) mirror.ccs.tencentyun.com(DNS idx:1)]
2024/02/27 01:19:07 [Debug] app/dns: domain mirror.ccs.tencentyun.com will use DNS in order: [UDP:114.114.114.114:53 UDP:114.114.114.114:53]
2024/02/27 01:19:07 [Debug] app/dns: UDP:114.114.114.114:53 querying DNS for: mirror.ccs.tencentyun.com.
2024/02/27 01:19:07 [Debug] transport/internet/udp: dispatch request to: udp:114.114.114.114:53
2024/02/27 01:19:07 [Debug] app/dns: domain mirror.ccs.tencentyun.com matches following rules: [geosite:cn(DNS idx:0) mirror.ccs.tencentyun.com(DNS idx:1)]
2024/02/27 01:19:07 [Debug] app/dns: domain mirror.ccs.tencentyun.com will use DNS in order: [UDP:114.114.114.114:53 UDP:114.114.114.114:53]
2024/02/27 01:19:07 [Debug] app/dns: UDP:114.114.114.114:53 querying DNS for: mirror.ccs.tencentyun.com.
2024/02/27 01:19:07 [Debug] transport/internet/udp: dispatch request to: udp:114.114.114.114:53
2024/02/27 01:19:08 [Info] app/dns: UDP:114.114.114.114:53 got answer: mirror.ccs.tencentyun.com. TypeA -> [] 270.547562ms
2024/02/27 01:19:08 [Debug] app/dns: UDP:114.114.114.114:53 updating IP records for domain:mirror.ccs.tencentyun.com.
2024/02/27 01:19:08 [Info] app/dns: UDP:114.114.114.114:53 got answer: mirror.ccs.tencentyun.com. TypeAAAA -> [] 270.453237ms
2024/02/27 01:19:08 [Debug] app/dns: UDP:114.114.114.114:53 updating IP records for domain:mirror.ccs.tencentyun.com.
2024/02/27 01:19:08 [Info] app/dns: failed to lookup ip for domain mirror.ccs.tencentyun.com at server UDP:114.114.114.114:53 > rcode: 3
2024/02/27 01:19:08 [Info] app/dns: failed to lookup ip for domain mirror.ccs.tencentyun.com at server UDP:114.114.114.114:53 > rcode: 3
进入容器内, 手动运行 dig 域名, 超时无结果.
个人推测, 是本机 Xray 的透明代理(Xray 针对本机 53 UDP 请求的代理) 造成 docker 域名解析出了问题, 请教解决方案.
谢谢.
@zw963 唔 docker
mirror.ccs.tencentyun.com 在公网上没有解析,需要🐧内网 DNS 解析
mirror.ccs.tencentyun.com在公网上没有解析,需要🐧内网 DNS 解析
这个域名有解析的。
mirror.ccs.tencentyun.com在公网上没有解析,需要🐧内网 DNS 解析这个域名有解析的。
https://www.itdog.cn/dns/mirror.ccs.tencentyun.com https://dig.ping.pe/mirror.ccs.tencentyun.com:A:8.8.8.8
我觉得是我以下在本机执行的路由规则造成的, 我的配置和大多数网上的没什么不同, 只不过不是在路由器上跑, 而是本机跑.(但是,奇怪的是, 如果在路由器上跑下面一样的规则, 然后本机 docker 不受影响, 本机直接跑就不行.)
我的规则如下:
iptables -t mangle -N V2RAY_UDP
iptables -t mangle -A V2RAY_UDP -d 127.0.0.1/8 -j RETURN
iptables -t mangle -A V2RAY_UDP -d 172.0.0.0/8 -j RETURN # 这个似乎被 docker 内部使用, 使用容器必须
iptables -t mangle -A V2RAY_UDP -d 255.255.255.255 -j RETURN
iptables -t mangle -A V2RAY_UDP -d 192.168.0.0/16 -p tcp -j RETURN
iptables -t mangle -A V2RAY_UDP -d 192.168.0.0/16 -p udp ! --dport 53 -j RETURN
iptables -t mangle -A V2RAY_UDP -d $v2ray_server_ip -j RETURN
iptables -t mangle -A V2RAY_UDP -j RETURN -m mark --mark 0xff
ip rule add fwmark 1 table 100
ip route add local default dev lo table 100
iptables -t mangle -A V2RAY_UDP -p udp -j TPROXY --on-ip 127.0.0.1 --on-port $local_v2ray_port --tproxy-mark 1
iptables -t mangle -A V2RAY_UDP -p tcp -j TPROXY --on-ip 127.0.0.1 --on-port $local_v2ray_port --tproxy-mark 1
iptables -t mangle -A PREROUTING -j V2RAY_UDP
iptables -t mangle -N V2RAY_MASK # 代理本机
iptables -t mangle -A V2RAY_MASK -d 127.0.0.1/8 -j RETURN
iptables -t mangle -A V2RAY_MASK -d 172.0.0.0/8 -j RETURN # 这个似乎被 docker 内部使用, 使用容器必须
iptables -t mangle -A V2RAY_MASK -d 255.255.255.255 -j RETURN
iptables -t mangle -A V2RAY_MASK -d 192.168.0.0/16 -p tcp -j RETURN
iptables -t mangle -A V2RAY_MASK -d 192.168.0.0/16 -p udp ! --dport 53 -j RETURN
iptables -t mangle -A V2RAY_MASK -d $v2ray_server_ip -j RETURN
iptables -t mangle -A V2RAY_MASK -p udp --dport 123 -j RETURN
iptables -t mangle -A V2RAY_MASK -p udp --dport 323 -j RETURN
iptables -t mangle -A V2RAY_MASK -j RETURN -m mark --mark 0xff
iptables -t mangle -A V2RAY_MASK -p udp -j MARK --set-mark 1 # 给 UDP 打标记,重路由
iptables -t mangle -A V2RAY_MASK -p tcp -j MARK --set-mark 1 # 给 TCP 打标记,重路由
iptables -t mangle -A OUTPUT -j V2RAY_MASK # 应用规则
至于 Xray 配置, 基本上和文档上一样的.
你本机访问的跟 docker 访问的都不是同一个地址。
你本机访问的跟 docker 访问的都不是同一个地址。
你说的什么地址不是同一个地址?
mirrors.cloud.tencent.com
哈,我搞错了。试了mirrors.cloud.tencent.com这个域名。
哈,我搞错了。试了mirrors.cloud.tencent.com这个域名。
mirrors.cloud.tencent.com 公网也有结果, 应该不是公网相关的问题吧.
Answered
Answered
It's seem like no answer work. :smile: