请教一个 redsocks + iptables 转全局的问题

92 views
Skip to first unread message

Marco

unread,
Feb 23, 2020, 1:39:22 AM2/23/20
to shlug
我的富强客户端在本地有一个 socks5_1080 的端口, 浏览器switchyProxy正常使用, gitconfig里配置一下也能用, polipo打成 http_proxy, 其它的软件都正常。

现在像用redsocks先将 sock5 转到 一个tcp端口上,然后配合iptables 实现整机全局富强(以及将来作为透明代理网关)

redsocks配置如下

base {
    log_debug = on;
    log_info = on;
    log = "syslog:daemon"; 
    daemon = on;
    user = redsocks;
    group = redsocks;
    redirector = iptables;
}
redsocks {
    local_ip = 127.0.0.1;
    local_port = 12345;
    ip = 127.0.0.1;
    port = 1080;
    type = socks5;
}


然后这是 iptables的脚本
iptables -t nat -N REDSOCKS

# Ignore LANs and some other reserved addresses.                                                                                  
iptables -t nat -A REDSOCKS -d <我的富强远程服务器ip> -j RETURN
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.1/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN

# Anything else should be redirected to port 12345                                                                                
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 12345


iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
iptables -t nat -A PREROUTING -p tcp -j REDSOCKS


感觉这些就应该可以了。可是。。。

  • 浏览器里, 打开google,显示 Your connection is not private……
  • 直接打开 mali.google.com 倒是可以?!
  • youtube 首页可以,但是播放不了(一直转圈圈)
  • kernel下载时,可以看到走的确实是富强
  • ipip.net 能打开,显示ip是富强服务器
我的dnsserver 是 8.8.8.8

请教是什么情况?




--
LinuX
Photography
Road Cycling

依云

unread,
Feb 23, 2020, 6:46:47 AM2/23/20
to sh...@googlegroups.com
On Sun, Feb 23, 2020 at 02:38:50PM +0800, Marco wrote:
> [...]
>
> - 浏览器里, 打开google,显示 Your connection is not private……
> - 直接打开 mali.google.com 倒是可以?!
> - youtube 首页可以,但是播放不了(一直转圈圈)
> - kernel下载时,可以看到走的确实是富强
> - ipip.net 能打开,显示ip是富强服务器
>
> 我的dnsserver 是 8.8.8.8
>
> 请教是什么情况?

DNS 不走 TCP,redsocks 处理不了。redsocks 的建议是 DNS 设置成它,它返回
个 truncated 标志,然后查询改走 TCP。你也可以开启火狐的 DoH 功能,或者自
己起个 DoH 或者 DoT 客户端。

--
Best regards,
lilydjwg

Marco

unread,
Feb 23, 2020, 6:20:15 PM2/23/20
to sh...@googlegroups.com
我Google的时候看过您的blog

dns还走普通的通道不行吗……被污染掉了?

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要在网络上查看此讨论,请访问 https://groups.google.com/d/msgid/shlug/20200223114605.GA3680332%40lilyforest.localdomain
--
Sent from my iPhone

Marco

unread,
Feb 23, 2020, 7:59:29 PM2/23/20
to shlug
真的耶。。。我在 resolv.conf 里加了 options use-vc 就可以了😀

非常感谢! 我再捣鼓捣鼓

Keine Neco

unread,
Feb 24, 2020, 9:42:40 PM2/24/20
to sh...@googlegroups.com
抛砖:现在的浏览器,并不是所有流量走tcp的 ,所以直接单纯redirect tcp流量并不能正确打开所有网站。google.com和youtube是非常典型的两个网站。
猜测:mail.google.com因为整个框架很古老,所以没有用这种新技术。
解决方案:
1. LAN里面继续使用socks5或者http proxy之类的方法来强制流量走TCP,然后再redirect socks5或者http proxy的流量。
2. 建立一个可以供udp使用的透传渠道,比如放弃polipo然后换用v2ray,在两个机器间建立v2ray的dokodemo-door或者ss-redir通道,然后用iptables把流量都打过去。
FYI:
QUIC:google用的基于udp的浏览器协议  https://en.wikipedia.org/wiki/QUIC



Marco <chopi...@gmail.com> 于2020年2月23日周日 下午2:39写道:
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/shlug/CAGgmW2igFBL7wgc3gsC54YakrjRVesZdi6r0skGXyujF1hxKpA%40mail.gmail.com

ximing

unread,
Feb 24, 2020, 9:59:25 PM2/24/20
to sh...@googlegroups.com

Rongxing Liu

unread,
Feb 29, 2020, 5:07:15 AM2/29/20
to sh...@googlegroups.com
我是用 dns-forwarder +  chinadns 的方案来解决DNS查询的问题。

ximing <zhaox...@gmail.com> 于2020年2月25日周二 上午10:59写道:

Marco

unread,
Mar 2, 2020, 10:00:32 PM3/2/20
to shlug
我回头试试看

Reply all
Reply to author
Forward
0 new messages