zfl9 / ipt2socks

将 iptables/nftables 传入的透明代理流量转为 socks5 流量的实用工具
GNU Affero General Public License v3.0
411 stars 94 forks source link

关于 -R选项 一个问题 #26

Closed cod1ingcoding closed 4 years ago

cod1ingcoding commented 4 years ago

-R选项:使用 REDIRECT(DNAT) 而非 TPROXY(针对 TCP)。 -R 选项为什么会让 -b 127.0.0.1 设置无效,直接绑定0.0.0.0? 我记得REDIRECT同样可以转发数据到127.0.0.1,只是要设置内核参数 net.ipv4.conf.all.route_localnet=1

zfl9 commented 4 years ago

-R 选项为什么会让 -b 127.0.0.1 设置无效,直接绑定0.0.0.0?

只需要将 -R 选项放在 -b/-B 选项之前,他就有效了。

记得REDIRECT同样可以转发数据到127.0.0.1,只是要设置内核参数

谢谢你,我现在才知道可以这么做,哈哈。

zfl9 commented 4 years ago
$ ipt2socks -R
2020-06-25 21:48:42 INF: [main] server address: 127.0.0.1#1080
2020-06-25 21:48:42 INF: [main] listen address: 0.0.0.0#60080
2020-06-25 21:48:42 INF: [main] listen address: ::#60080
2020-06-25 21:48:42 INF: [main] udp cache maximum size: 256
2020-06-25 21:48:42 INF: [main] udp socket idle timeout: 60
2020-06-25 21:48:42 INF: [main] number of worker threads: 1
2020-06-25 21:48:42 INF: [main] enable tcp transparent proxy
2020-06-25 21:48:42 INF: [main] enable udp transparent proxy
2020-06-25 21:48:42 INF: [main] use redirect instead of tproxy
^C
$ ipt2socks -R -b127.0.0.1 -B::1
2020-06-25 21:48:54 INF: [main] server address: 127.0.0.1#1080
2020-06-25 21:48:54 INF: [main] listen address: 127.0.0.1#60080
2020-06-25 21:48:54 INF: [main] listen address: ::1#60080
2020-06-25 21:48:54 INF: [main] udp cache maximum size: 256
2020-06-25 21:48:54 INF: [main] udp socket idle timeout: 60
2020-06-25 21:48:54 INF: [main] number of worker threads: 1
2020-06-25 21:48:54 INF: [main] enable tcp transparent proxy
2020-06-25 21:48:54 INF: [main] enable udp transparent proxy
2020-06-25 21:48:54 INF: [main] use redirect instead of tproxy
zfl9 commented 4 years ago

至于要不要改变这个默认行为,我个人愚见,就不改了(懒得改了~~)。我想大多数人也是不知道这个 sysctl 选项的。如果确实关心监听地址为 0:0:0:0,那么自己调换下选项的顺序即可,问题也不大。

cod1ingcoding commented 4 years ago

只需要将 -R 选项放在 -b/-B 选项之前,他就有效了。

还有这种操作,好的。