首页 > 求教ss-redir的iptables设置

求教ss-redir的iptables设置

我在电脑上用hostapd来架设了一个AP,然后使用ss-redir来转发所有连上这个AP的数据,但iptables设置却怎么也配置不通,特来求教。

电脑的有线网络IP是192.168.11.2,网关是192.168.11.1,有Internet连接。
AP上电脑IP是192.168.111.1,手机的IP是192.168.111.2
ss-redir监听的IP是0.0.0.0,端口是1080

我想让电脑还是直接访问Internet,而连上AP的手机是通过SS访问Internet。
现在AP工作正常,手机可以访问到电脑上架设的nginx的内容,但是却无法访问Internet。

添加了如下iptables规则:

iptables -t nat -N SS
iptables -t nat -A SS -d 192.168.111.1 -j RETURN
iptables -t nat -A SS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A SS -p tcp -j REDIRECT --to-ports 1080
#上一句改成iptables -t nat -A SS -p -j DNAT --to 127.0.0.1:1080也一样无效

iptables -t nat -A PREROUTING -s 192.168.111.0/24 -j SS
【热门文章】
【热门文章】