TUN似乎无法正确处理127.0.0.0/8出站(常见于端口转发)
完整性要求
- [x] 我读完了 issue 模板中的所有注释,确保填写符合要求。
- [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- [x] 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- [x] 我搜索了 issues, 没有发现已提出的类似问题。
- [x] 问题在 Release 最新的版本上可以成功复现
描述
按照V2rayN默认推荐设置,Xray-core的TUN无法正确连接(依赖第三方程序的端口转发)127.0.0.1:port,而直接连接服务器对应端口正常,第三方程序提供的隧道工作正常,疑似该配置下TUN未正确处理回环IP,导出配置后使用命令行sudo ./xray启动无差别 下面客户端日志为info,实际使用debug未发现有效信息
重现方式
服务器端使用下面的配置,使用ssh -L 端口转发,以管理员权限启动xray。 (未必需要SSH,只是示例)
客户端配置
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"tag": "socks",
"port": 7890,
"listen": "127.0.0.1",
"protocol": "mixed",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
},
{
"tag": "tun",
"protocol": "tun",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"name": "xray_tun",
"MTU": 9000,
"gateway": [
"172.18.0.1/30",
"fdfe:dcba:9876::1/126"
],
"autoSystemRoutingTable": [
"0.0.0.0/0",
"::/0"
],
"autoOutboundsInterface": "auto"
}
},
{
"tag": "api",
"port": 7894,
"listen": "127.0.0.1",
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
}
}
],
"outbounds": [
{
"tag": "proxy",
"protocol": "vless",
"targetStrategy": "UseIPv4v6",
"settings": {
"vnext": [
{
"address": "127.0.0.1",
"port": 1280,
"users": [
{
"id": "id",
"email": "[email protected]",
"security": "auto",
"encryption": "mlkem768x25519plus.native.0rtt.xxxxxxx",
"flow": "xtls-rprx-vision-udp443"
}
]
}
]
},
"streamSettings": {
"network": "raw"
},
"mux": {
"enabled": false,
"concurrency": -1
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4v6",
"userLevel": 0
}
},
{
"tag": "block",
"protocol": "blackhole"
},
{
"tag": "dns",
"protocol": "dns"
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"inboundTag": [
"api"
],
"outboundTag": "api"
},
{
"port": "135,137-139,5353",
"network": "udp",
"outboundTag": "block"
},
{
"outboundTag": "block",
"ip": [
"224.0.0.0/3",
"ff00::/8"
]
},
{
"port": "53",
"outboundTag": "dns",
"process": [
"v2ray.exe",
"mihomo-windows-amd64-v1.exe",
"mihomo-windows-amd64-compatible.exe",
"mihomo-windows-amd64.exe",
"mihomo-windows-arm64.exe",
"clash.exe",
"mihomo.exe",
"hysteria.exe",
"naive.exe",
"naiveproxy.exe",
"tuic-client.exe",
"tuic.exe",
"sing-box-client.exe",
"sing-box.exe",
"juicity-client.exe",
"juicity.exe",
"hysteria-windows-amd64.exe",
"hysteria-linux-amd64.exe",
"brook_windows_amd64.exe",
"brook_linux_amd64.exe",
"brook.exe",
"overtls-bin.exe",
"overtls.exe",
"shadowquic.exe",
"mieru.exe"
]
},
{
"outboundTag": "direct",
"process": [
"v2ray.exe",
"xray.exe",
"mihomo-windows-amd64-v1.exe",
"mihomo-windows-amd64-compatible.exe",
"mihomo-windows-amd64.exe",
"mihomo-windows-arm64.exe",
"clash.exe",
"mihomo.exe",
"hysteria.exe",
"naive.exe",
"naiveproxy.exe",
"tuic-client.exe",
"tuic.exe",
"sing-box-client.exe",
"sing-box.exe",
"juicity-client.exe",
"juicity.exe",
"hysteria-windows-amd64.exe",
"hysteria-linux-amd64.exe",
"brook_windows_amd64.exe",
"brook_linux_amd64.exe",
"brook.exe",
"overtls-bin.exe",
"overtls.exe",
"shadowquic.exe",
"mieru.exe",
"xray/",
"self/"
]
},
{
"port": "53",
"outboundTag": "dns"
},
{
"type": "field",
"outboundTag": "block",
"domain": [
"geosite:facebook",
"geosite:netflix",
"geosite:telegram",
"geosite:twitter",
"keyword:x.com"
]
},
{
"type": "field",
"outboundTag": "block",
"ip": [
"geoip:facebook",
"geoip:netflix",
"geoip:telegram",
"geoip:twitter"
]
},
{
"type": "field",
"outboundTag": "direct",
"ip": [
"geoip:private"
]
},
{
"type": "field",
"outboundTag": "direct",
"domain": [
"geosite:private"
]
},
{
"type": "field",
"outboundTag": "proxy",
"process": [
"VboxNetNAT.exe",
"VBoxNetNAT",
"java",
"javaw"
]
},
{
"type": "field",
"outboundTag": "proxy",
"domain": [
"domain:cloudflare-dns.com",
"domain:one.one.one.one",
"domain:dns.google",
"domain:adguard-dns.com",
"domain:opendns.com",
"domain:umbrella.com",
"domain:quad9.net",
"domain:yandex.net"
]
},
{
"type": "field",
"outboundTag": "proxy",
"ip": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
"1.1.1.2",
"1.0.0.2",
"2606:4700:4700::1112",
"2606:4700:4700::1002",
"1.1.1.3",
"1.0.0.3",
"2606:4700:4700::1113",
"2606:4700:4700::1003",
"8.8.8.8",
"8.8.4.4",
"2001:4860:4860::8888",
"2001:4860:4860::8844",
"94.140.14.14",
"94.140.15.15",
"2a10:50c0::ad1:ff",
"2a10:50c0::ad2:ff",
"94.140.14.15",
"94.140.15.16",
"2a10:50c0::bad1:ff",
"2a10:50c0::bad2:ff",
"94.140.14.140",
"94.140.14.141",
"2a10:50c0::1:ff",
"2a10:50c0::2:ff",
"208.67.222.222",
"208.67.220.220",
"2620:119:35::35",
"2620:119:53::53",
"208.67.222.123",
"208.67.220.123",
"2620:119:35::123",
"2620:119:53::123",
"9.9.9.9",
"149.112.112.112",
"2620:fe::9",
"2620:fe::fe",
"9.9.9.11",
"149.112.112.11",
"2620:fe::11",
"2620:fe::fe:11",
"9.9.9.10",
"149.112.112.10",
"2620:fe::10",
"2620:fe::fe:10",
"77.88.8.8",
"77.88.8.1",
"2a02:6b8::feed:0ff",
"2a02:6b8:0:1::feed:0ff",
"77.88.8.88",
"77.88.8.2",
"2a02:6b8::feed:bad",
"2a02:6b8:0:1::feed:bad",
"77.88.8.7",
"77.88.8.3",
"2a02:6b8::feed:a11",
"2a02:6b8:0:1::feed:a11"
]
},
{
"type": "field",
"port": "0-65535",
"outboundTag": "direct"
},
{
"type": "field",
"inboundTag": [
"direct-dns-1",
"direct-dns-2",
"direct-dns-3",
"direct-dns-4",
"direct-dns-5",
"direct-dns-6",
"direct-dns-7",
"direct-dns-8"
],
"outboundTag": "direct"
},
{
"type": "field",
"inboundTag": [
"dns-module"
],
"outboundTag": "proxy"
}
]
},
"metrics": {
"tag": "api"
},
"policy": {
"system": {
"statsOutboundUplink": true,
"statsOutboundDownlink": true
}
},
"stats": {}
}
"dns": {
"hosts": {
"dns.google": [
"8.8.8.8",
"8.8.4.4",
"2001:4860:4860::8888",
"2001:4860:4860::8844"
],
"dns.alidns.com": [
"223.5.5.5",
"223.6.6.6",
"2400:3200::1",
"2400:3200:baba::1"
],
"one.one.one.one": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001"
],
"1dot1dot1dot1.cloudflare-dns.com": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001"
],
"cloudflare-dns.com": [
"104.16.249.249",
"104.16.248.249",
"2606:4700::6810:f8f9",
"2606:4700::6810:f9f9"
],
"dns.cloudflare.com": [
"104.16.132.229",
"104.16.133.229",
"2606:4700::6810:84e5",
"2606:4700::6810:85e5"
],
"dot.pub": [
"1.12.12.12",
"120.53.53.53"
],
"doh.pub": [
"1.12.12.12",
"120.53.53.53"
],
"dns.quad9.net": [
"9.9.9.9",
"149.112.112.112",
"2620:fe::fe",
"2620:fe::9"
],
"dns.yandex.net": [
"77.88.8.8",
"77.88.8.1",
"2a02:6b8::feed:0ff",
"2a02:6b8:0:1::feed:0ff"
],
"dns.sb": [
"185.222.222.222",
"2a09::"
],
"dns.umbrella.com": [
"208.67.220.220",
"208.67.222.222",
"2620:119:35::35",
"2620:119:53::53"
],
"dns.sse.cisco.com": [
"208.67.220.220",
"208.67.222.222",
"2620:119:35::35",
"2620:119:53::53"
],
"engage.cloudflareclient.com": [
"162.159.192.1"
]
},
"servers": [
{
"address": "https://cloudflare-dns.com/dns-query",
"domains": [
"domain:cloudflare-dns.com",
"domain:one.one.one.one",
"domain:dns.google",
"domain:adguard-dns.com",
"domain:opendns.com",
"domain:umbrella.com",
"domain:quad9.net",
"domain:yandex.net"
],
"skipFallback": true
},
{
"address": "https://dns.google/dns-query",
"domains": [
"domain:cloudflare-dns.com",
"domain:one.one.one.one",
"domain:dns.google",
"domain:adguard-dns.com",
"domain:opendns.com",
"domain:umbrella.com",
"domain:quad9.net",
"domain:yandex.net"
],
"skipFallback": true
},
{
"address": "8.8.8.8",
"domains": [
"domain:cloudflare-dns.com",
"domain:one.one.one.one",
"domain:dns.google",
"domain:adguard-dns.com",
"domain:opendns.com",
"domain:umbrella.com",
"domain:quad9.net",
"domain:yandex.net"
],
"skipFallback": true
},
{
"address": "1.1.1.1",
"domains": [
"geosite:private"
],
"skipFallback": true,
"tag": "direct-dns-1"
},
{
"address": "1.2.4.8",
"domains": [
"geosite:private"
],
"skipFallback": true,
"tag": "direct-dns-2"
},
{
"address": "119.29.29.29",
"domains": [
"geosite:private"
],
"skipFallback": true,
"tag": "direct-dns-3"
},
{
"address": "223.5.5.5",
"domains": [
"geosite:private"
],
"skipFallback": true,
"tag": "direct-dns-4"
},
{
"address": "119.29.29.29",
"domains": [
"full:cloudflare-dns.com",
"full:dns.google"
],
"skipFallback": true
},
{
"address": "1.1.1.1",
"skipFallback": false,
"tag": "direct-dns-5"
},
{
"address": "1.2.4.8",
"skipFallback": false,
"tag": "direct-dns-6"
},
{
"address": "119.29.29.29",
"skipFallback": false,
"tag": "direct-dns-7"
},
{
"address": "223.5.5.5",
"skipFallback": false,
"tag": "direct-dns-8"
}
],
"serveStale": true,
"enableParallelQuery": true,
"tag": "dns-module"
},
服务端配置
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 1280,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "id",
"level": 0,
"email": "root@localhost",
"flow": "xtls-rprx-vision"
}
],
"decryption": "mlkem768x25519plus.native.600s.xxxx"
},
"sniffing": {
"enabled": false,
"destOverride": [
"http",
"tls",
"quic"
],
"routeOnly": true
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "blocked"
}
]
}
}
客户端日志
debug模式刷屏出现大量奇怪的本地IP提示,均为169.254.0.0/16,呈递增趋势,未发现其他有关信息
服务端日志
检查后未发现任何信息,只有核心成功启动,开始监听的信息(疑似未收到任何请求)
autoOutboundsInterface 会自动把默认device bind到真实网卡 需要手动在sockopt指回lo