kcptun icon indicating copy to clipboard operation
kcptun copied to clipboard

使用kcptun加速来访问内网单个端口,局域网测试没问题,穿透Openwrt时,端口转发或直接把服务设置在路由器上都不行

Open BillYao9 opened this issue 3 years ago • 0 comments

内网的NAS直接开放端口用于外部访问,速度不稳定,百兆的宽带,有时6-7M/s下载,很多时间只有600-700KB/s. 试图使用kcptun加速来提高速度. 但是外网无法访问网页或ssh或其他. NAS上设置kcptun服务端, Openwrt路由器转发UDP端口到NAS.

局域网内 设置kcptun客户端, 直接连接NAS 或者连接外网IP 都可以访问NAS网页. 外部访问时,可以连接,但是无法访问网页,也测试过ssh连接,同样内网可以访问,外网不可以访问. 两种访问方式使用了同样的配置文件.

外部访问时,服务端1分钟后 stream close 并出现 io: read/write on closed pipe

怀疑与Openwrt本身或者端口转发有关. 难道是运营商有限制 测试过直接将kcptun服务设置在openwrt上,同样的问题,外部不能访问. 测试过使用kcptun访问vps内部的网页.没有问题.

外部访问时 客户端的日志: PS D:\Desktop> .\kcptun.exe -c .\local.json 2021/10/09 10:45:33 version: 20210922 2021/10/09 10:45:33 smux version: 1 2021/10/09 10:45:33 listening on: [::]:5555 2021/10/09 10:45:33 encryption: aes 2021/10/09 10:45:33 nodelay parameters: 1 10 2 1 2021/10/09 10:45:33 remote address: 222...:24670 2021/10/09 10:45:33 sndwnd: 1024 rcvwnd: 1024 2021/10/09 10:45:33 compression: false 2021/10/09 10:45:33 mtu: 1350 2021/10/09 10:45:33 datashard: 10 parityshard: 3 2021/10/09 10:45:33 acknodelay: false 2021/10/09 10:45:33 dscp: 0 2021/10/09 10:45:33 sockbuf: 16777217 2021/10/09 10:45:33 smuxbuf: 4194304 2021/10/09 10:45:33 streambuf: 2097152 2021/10/09 10:45:33 keepalive: 10 2021/10/09 10:45:33 conn: 1 2021/10/09 10:45:33 autoexpire: 0 2021/10/09 10:45:33 scavengettl: 600 2021/10/09 10:45:33 snmplog: 2021/10/09 10:45:33 snmpperiod: 60 2021/10/09 10:45:33 quiet: false 2021/10/09 10:45:33 tcp: false 2021/10/09 10:45:33 initiating key derivation 2021/10/09 10:45:33 key derivation done 2021/10/09 10:45:37 smux version: 1 on connection: 0.0.0.0:61096 -> 222...:24670 2021/10/09 10:45:37 stream opened in: [::1]:10979 out: 222...:24670(3) 2021/10/09 10:45:37 stream opened in: [::1]:5115 out: 222...:24670(5) 2021/10/09 10:46:07 stream closed in: [::1]:5115 out: 222...:24670(5) 2021/10/09 10:46:07 stream closed in: [::1]:10979 out: 222...:24670(3) 2021/10/09 10:46:07 smux version: 1 on connection: 0.0.0.0:65350 -> 222...:24670 2021/10/09 10:46:07 stream opened in: [::1]:6745 out: 222...:24670(3) 2021/10/09 10:46:37 stream closed in: [::1]:6745 out: 222...*:24670(3)

局域网访问时 客户端的日志: D:\Desktop>kcptun.exe -c local.json 2021/10/09 10:43:31 version: 20210922 2021/10/09 10:43:31 smux version: 1 2021/10/09 10:43:31 listening on: [::]:5555 2021/10/09 10:43:31 encryption: aes 2021/10/09 10:43:31 nodelay parameters: 1 10 2 1 2021/10/09 10:43:31 remote address: 222...:24670 2021/10/09 10:43:31 sndwnd: 1024 rcvwnd: 1024 2021/10/09 10:43:31 compression: false 2021/10/09 10:43:31 mtu: 1350 2021/10/09 10:43:31 datashard: 10 parityshard: 3 2021/10/09 10:43:31 acknodelay: false 2021/10/09 10:43:31 dscp: 0 2021/10/09 10:43:31 sockbuf: 16777217 2021/10/09 10:43:31 smuxbuf: 4194304 2021/10/09 10:43:31 streambuf: 2097152 2021/10/09 10:43:31 keepalive: 10 2021/10/09 10:43:31 conn: 1 2021/10/09 10:43:31 autoexpire: 0 2021/10/09 10:43:31 scavengettl: 600 2021/10/09 10:43:31 snmplog: 2021/10/09 10:43:31 snmpperiod: 60 2021/10/09 10:43:31 quiet: false 2021/10/09 10:43:31 tcp: false 2021/10/09 10:43:31 initiating key derivation 2021/10/09 10:43:31 key derivation done 2021/10/09 10:43:59 smux version: 1 on connection: 0.0.0.0:52425 -> 222...:24670 2021/10/09 10:43:59 stream opened in: [::1]:9730 out: 222...:24670(3) 2021/10/09 10:43:59 stream opened in: [::1]:11329 out: 222...:24670(5) 2021/10/09 10:43:59 stream opened in: [::1]:1870 out: 222...:24670(7) 2021/10/09 10:43:59 stream opened in: [::1]:2581 out: 222...:24670(9) 2021/10/09 10:43:59 stream opened in: [::1]:9162 out: 222...:24670(11) 2021/10/09 10:43:59 stream opened in: [::1]:5117 out: 222...:24670(13) 2021/10/09 10:45:04 stream closed in: [::1]:2581 out: 222...:24670(9) 2021/10/09 10:45:04 stream closed in: [::1]:1870 out: 222...:24670(7) 2021/10/09 10:45:04 stream closed in: [::1]:9730 out: 222...:24670(3) 2021/10/09 10:45:04 stream closed in: [::1]:11329 out: 222...:24670(5) 2021/10/09 10:45:04 stream closed in: [::1]:5117 out: 222...:24670(13) 2021/10/09 10:45:04 stream closed in: [::1]:9162 out: 222...:24670(11)

NAS服务端日志: /server_linux_amd64 -c server.json 2021/10/09 10:43:41 version: 20210922 2021/10/09 10:43:41 smux version: 1 2021/10/09 10:43:41 listening on: :12345 2021/10/09 10:43:41 target: 0.0.0.0:5000 2021/10/09 10:43:41 encryption: aes 2021/10/09 10:43:41 nodelay parameters: 1 10 2 1 2021/10/09 10:43:41 sndwnd: 1024 rcvwnd: 1024 2021/10/09 10:43:41 compression: false 2021/10/09 10:43:41 mtu: 1350 2021/10/09 10:43:41 datashard: 10 parityshard: 3 2021/10/09 10:43:41 acknodelay: false 2021/10/09 10:43:41 dscp: 0 2021/10/09 10:43:41 sockbuf: 16777217 2021/10/09 10:43:41 smuxbuf: 4194304 2021/10/09 10:43:41 streambuf: 2097152 2021/10/09 10:43:41 keepalive: 10 2021/10/09 10:43:41 snmplog: 2021/10/09 10:43:41 snmpperiod: 60 2021/10/09 10:43:41 pprof: false 2021/10/09 10:43:41 quiet: false 2021/10/09 10:43:41 tcp: false 2021/10/09 10:43:41 initiating key derivation 2021/10/09 10:43:41 key derivation done 2021/10/09 10:43:50 remote address: 10.10.10.1:52425 2021/10/09 10:43:50 smux version: 1 on connection: [::]:12345 -> 10.10.10.1:52425 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(3) out: 127.0.0.1:5000 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(5) out: 127.0.0.1:5000 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(7) out: 127.0.0.1:5000 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(9) out: 127.0.0.1:5000 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(11) out: 127.0.0.1:5000 2021/10/09 10:43:50 stream opened in: 10.10.10.1:52425(13) out: 127.0.0.1:5000 2021/10/09 10:44:55 stream closed in: 10.10.10.1:52425(9) out: 127.0.0.1:5000 2021/10/09 10:44:55 stream closed in: 10.10.10.1:52425(7) out: 127.0.0.1:5000 2021/10/09 10:44:55 stream closed in: 10.10.10.1:52425(3) out: 127.0.0.1:5000 2021/10/09 10:44:55 stream closed in: 10.10.10.1:52425(13) out: 127.0.0.1:5000 2021/10/09 10:44:55 stream closed in: 10.10.10.1:52425(5) out: 127.0.0.1:5000 2021/10/09 10:44:56 stream closed in: 10.10.10.1:52425(11) out: 127.0.0.1:5000 2021/10/09 10:45:37 remote address: 61...:5516 2021/10/09 10:45:37 smux version: 1 on connection: [::]:12345 -> 61...:5516 2021/10/09 10:45:37 stream opened in: 61...:5516(5) out: 127.0.0.1:5000 2021/10/09 10:45:37 stream opened in: 61...:5516(3) out: 127.0.0.1:5000 2021/10/09 10:45:47 stream closed in: 61...:5516(5) out: 127.0.0.1:5000 2021/10/09 10:46:07 remote address: 61...:3799 2021/10/09 10:46:07 smux version: 1 on connection: [::]:12345 -> 61...:3799 2021/10/09 10:46:07 stream opened in: 61...:3799(3) out: 127.0.0.1:5000 2021/10/09 10:46:37 io: read/write on closed pipe 2021/10/09 10:46:37 stream closed in: 61...:5516(3) out: 127.0.0.1:5000 2021/10/09 10:47:07 io: read/write on closed pipe 2021/10/09 10:47:07 stream closed in: 61...:3799(3) out: 127.0.0.1:5000

NAS端netstat 信息 局域网访问时 root@NAS:~# netstat -antplu | grep 5000 tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 11341/nginx: master tcp 0 0 127.0.0.1:52970 127.0.0.1:5000 ESTABLISHED 22586/./server_linu tcp 0 0 127.0.0.1:5000 127.0.0.1:52970 ESTABLISHED 13299/nginx: worker tcp 0 0 127.0.0.1:5000 127.0.0.1:52968 ESTABLISHED 13298/nginx: worker tcp 0 0 127.0.0.1:52968 127.0.0.1:5000 ESTABLISHED 22586/./server_linu tcp6 0 0 :::5000 :::* LISTEN 11341/nginx: master 外部也访问时, root@NAS:~# netstat -antplu | grep 5000 tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 11341/nginx: master tcp 0 0 127.0.0.1:52970 127.0.0.1:5000 ESTABLISHED 22586/./server_linu tcp 0 0 127.0.0.1:5000 127.0.0.1:52970 ESTABLISHED 13299/nginx: worker tcp 0 0 127.0.0.1:5000 127.0.0.1:52968 ESTABLISHED 13298/nginx: worker tcp 0 0 127.0.0.1:52968 127.0.0.1:5000 ESTABLISHED 22586/./server_linu

tcp 0 0 127.0.0.1:52972 127.0.0.1:5000 ESTABLISHED 22586/./server_linu ## 外部访问时 tcp 0 0 127.0.0.1:5000 127.0.0.1:52974 ESTABLISHED 13299/nginx: worker tcp 0 0 127.0.0.1:5000 127.0.0.1:52972 ESTABLISHED 13299/nginx: worker tcp 0 0 127.0.0.1:52974 127.0.0.1:5000 ESTABLISHED 22586/./server_linu

tcp6 0 0 :::5000 :::* LISTEN 11341/nginx: master

BillYao9 avatar Oct 09 '21 03:10 BillYao9