我在家用 PC 上尝试结合使用 tor 和 privoxy 时遇到了类似的错误。
使用的操作系统是 Kali Linux 2.0。
复制问题的步骤
安装的tor
sudo apt-get install tor
启动 Tor 中继
tor
验证 tor 是否工作
netstat -atnp tor | egrep tor
在输出中,观察到 Tor 输出——很好。
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 2401/tor
tcp 0 0 192.168.x.x:44278 xx.xxx.xx.xx:443 ESTABLISHED 2401/tor
安装的privoxy
sudo apt-get install privoxy
根据“如何将 privoxy 与 tor 一起使用”下的说明 here 修改 /etc/privoxy/config 中的默认 privoxy 配置文件,并包括以下几行:
forward-socks4a 127.0.0.1:9050 .
forward 192.168.*.*/ .
forward 10.*.*.*/ .
forward 127.*.*.*/ .
然后开始privoxy
privoxy /etc/privoxy/config
运行命令检查 privoxy 是否工作:
netstat -atnp | egrep privoxy
输出显示 privoxy 正在运行(注意 tcp6 是 IPv6 - 我一开始没有注意,但这就是问题):
tcp6 0 0 ::1:8118 :::* LISTEN 3881/privoxy
然后将 SSL 和 HTTP 代理设置为 127.0.0.1:8118,我在浏览互联网站点时收到错误消息,“选择的代理拒绝连接”
修复:
仔细阅读 privoxy 配置文件后,listen-address 节显示以下信息。
Some operating systems will prefer IPv6 to IPv4 addresses even
if the system has no IPv6 connectivity which is usually not
expected by the user. Some even rely on DNS to resolve
localhost which mean the "localhost" address used may not
actually be local.
**It is therefore recommended to explicitly configure the
intended IP address instead of relying on the operating
system, unless there's a strong reason not to.**
似乎 KALI 更喜欢绑定到 IPv6 本地主机 [::1] 而不是 IPv4 本地主机 127.0.0.1,即使我没有 IPv6 连接。
所以我从
更改了监听地址行
listen-address localhost:8118
到
listen-address 127.0.0.1:8118
并重新启动 privoxy...
pkill privoxy # kills all processes with privoxy in their name
privoxy /etc/privoxy/config
然后,我在 ICEWEASEL 中将 SSL、HTTP 代理设置为 127.0.0.1:8118,将 SOCKS 代理设置为 127.0.0.1:9050(Socks 4)。瞧!我能够连接到互联网站点。
为了验证,我运行了 netstat 和 nmap,显示 privoxy 绑定到 IPv4 localhost IP..
> netstat -atnp | grep privoxy
tcp 0 0 127.0.0.1:8118 0.0.0.0:* LISTEN 3934/privoxy
> nmap 127.0.0.1 -p 8118
PORT STATE SERVICE
8118/tcp open privoxy
> nmap -6 localhost -p 8118
PORT STATE SERVICE
8118/tcp closed privoxy
注意:
我的 /etc/hosts 文件也有 localhost 的条目:
127.0.0.1 本地主机