我正在尝试配置 iptables 来获取红袜队工作{目的是获取系统范围的袜子代理}
#!/bin/bash
# Create new chain
iptables -t nat -N REDSOCKS
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.0/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
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 8888
iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner USER -j REDSOCKS
我得到以下内容
iptables: No chain/target/match by that name.
iptables: No chain/target/match by that name.
我认为导致此问题的原因是 -j REDIRECT --to-ports 例如,当我尝试时
iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-port 8888
仍然给我那个
使用这个我可以让 redsocks 工作,但它将所有内容重定向到 127.0.0.1:8888 ,例如,当我打开 google.com 时,它会转到 127.0.0.1:8888 但 url 仍然是 google.com
#!/bin/bash
iptables -t nat -N REDSOCKS
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.0/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
iptables -t nat -A REDSOCKS -p tcp -o eth0 -j DNAT --to 127.0.0.1:8888
iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
这是我的 redsocks.conf
base {
log_debug = on;
log_info = on;
daemon = on;
log = "file:redsocks.log";
redirector = iptables;
}
redsocks {
local_ip = 127.0.0.1;
local_port = 12345;
ip = 127.0.0.1;
port = 8888;
type = socks5;
}