semigodking / redsocks

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

redsocks{} tcp tproxy 使用 #121

Open nutinshell opened 5 years ago

nutinshell commented 5 years ago

目前在repo里找到的办法都不是很详细,请问现在 redsocks {} 支持 tcp 的 tproxy 转发么?例如:

redsocks {
 local_ip = 0.0.0.0;
 local_port = 3129;
 ip = 127.0.0.1;
 port = 2000;
 type = socks5;
 listenq = 2048;
 max_accept_backoff = 60000;
 autoproxy = 0;
}
base {
 log_debug = off;
 log_info = on;
 log = "file:/var/log/redsocks.log";
 daemon = on;
 redirector = iptables;
}

配合 iptables 转发流量呢?在Ubuntu 4.18的内核里测试了下似乎没有成功。感谢任何指明。

iptables -t mangle -N DIVERT
iptables -t mangle -A DIVERT -j MARK --set-mark 111
iptables -t mangle -A DIVERT -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j TPROXY --on-port 3129 --on-ip 0.0.0.0 --tproxy-mark 0x6f/0xffffffff
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 443 -j TPROXY --on-port 3129 --on-ip 0.0.0.0 --tproxy-mark 0x6f/0xffffffff

ip rule add fwmark 111 lookup 100
ip route add local default dev lo table 100

错误:

warning base.c:243 getdestaddr_iptables(...) getsockopt: Protocol not available
semigodking commented 5 years ago

支持tproxy的。这应该是之前kernel的一个bug,你换个kernel吧。

nutinshell commented 5 years ago

支持tproxy的。这应该是之前kernel的一个bug,你换个kernel吧。

谢谢。试了换成 4.15 的内核,还是一样的错误。

semigodking commented 5 years ago

那我得回头找个相应版本的系统试试才行。 tproxy 肯定是支持的。

nutinshell notifications@github.com 于 2019年6月17日周一 23:53写道:

支持tproxy的。这应该是之前kernel的一个bug,你换个kernel吧。

谢谢。试了换成 4.15 的内核,还是一样的错误。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/semigodking/redsocks/issues/121?email_source=notifications&email_token=AAP2XD2FVWMD5JT4R5NXHMDP26XPDA5CNFSM4HYRY7KKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX3TXJA#issuecomment-502741924, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP2XD2IESZ2WTFDJXTGTCTP26XPDANCNFSM4HYRY7KA .