semigodking / redsocks

transparent redirector of any TCP/UDP connection to proxy
Apache License 2.0
1.17k stars 247 forks source link

UDP透明代理出现 socks5_relay_error #166

Open swiftech opened 3 years ago

swiftech commented 3 years ago

网关设备192.168.1.4在20008端口有SOCKS5,经客户端测试连接有效,配置 redudp 端口2009转发到20008端口,iptables TPROXY 将 53 端口转到2009端口 ,从另外一台机器 192.168.1.80做dns查询 dig @8.8.8.8 google.com 报错:socks5_relay_error,详细配置和信息如下,请帮忙看一下,谢谢

配置: base { log_debug = on; log_info = on; daemon = on; redirector = iptables; } redsocks { local_ip = 0.0.0.0; local_port = 2008; ip = 127.0.0.1; port = 20008; type = socks5; autoproxy = 0; } tcpdns { local_ip = 192.168.1.44; local_port = 1053; tcpdns1 = 8.8.4.4; tcpdns2 = 8.8.8.8; timeout = 20; } redudp { local_ip = 0.0.0.0; local_port = 2009; ip = 127.0.0.1; port = 20008; type = socks5; udp_timeout = 20; }

ip rule add fwmark 1 lookup 100 ip route add local 0.0.0.0/0 dev lo table 100 iptables -t mangle -N DNS_REDSOCKS2_TCP iptables -t mangle -A DNS_REDSOCKS2_TCP -p udp --dport 53 -j TPROXY --on-ip 192.168.1.44 --on-port 2009 --tproxy-mark 0x01/0x01

日志输出: Mon Aug 9 09:29:01 2021 daemon.debug redsocks[19118]: Audit client list for instance (socks5 @ 0.0.0.0:2008): Mon Aug 9 09:29:01 2021 daemon.debug redsocks[19118]: End of auditing client list. Mon Aug 9 09:29:17 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: got 1st packet from client Mon Aug 9 09:29:17 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: via 127.0.0.1:20008 Mon Aug 9 09:29:17 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Mon Aug 9 09:29:17 2021 daemon.notice redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: socks5_relay_error Mon Aug 9 09:29:17 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Dropping client @ state: 0 Mon Aug 9 09:29:22 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: got 1st packet from client Mon Aug 9 09:29:22 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: via 127.0.0.1:20008 Mon Aug 9 09:29:22 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Mon Aug 9 09:29:22 2021 daemon.notice redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: socks5_relay_error Mon Aug 9 09:29:22 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Dropping client @ state: 0 Mon Aug 9 09:29:26 2021 daemon.debug redsocks[19118]: [192.168.1.88:51213->44.241.185.165:443]: RCB relay, in: 31 Mon Aug 9 09:29:26 2021 daemon.debug redsocks[19118]: [192.168.1.88:51213->44.241.185.165:443]: WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0 Mon Aug 9 09:29:26 2021 daemon.debug redsocks[19118]: [192.168.1.88:51213->44.241.185.165:443]: RCB client, in: 35 Mon Aug 9 09:29:26 2021 daemon.debug redsocks[19118]: [192.168.1.88:51213->44.241.185.165:443]: WCB relay, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0 Mon Aug 9 09:29:27 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: got 1st packet from client Mon Aug 9 09:29:27 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: via 127.0.0.1:20008 Mon Aug 9 09:29:27 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Mon Aug 9 09:29:27 2021 daemon.notice redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: socks5_relay_error Mon Aug 9 09:29:27 2021 daemon.debug redsocks[19118]: [192.168.1.80:52281->8.8.8.8:53]: Dropping client @ state: 0

semigodking commented 3 years ago

我看了一会儿,没看出问题在哪里。只能看到socks5的连接关闭了,但不知道原因。而且我也没找到哪一行会导致产生那一个空log

semigodking commented 3 years ago

建议抓个包吧。