我有一个监听http://localhost:3000的服务器,并且我想将所有请求从Chrome扩展(一些JSON数据)转发到http://api.lingualeo.com/addword到http://localhost:3000 。
我做了什么:
# sysctl -w net/ipv4/conf/all/route_localnet=1 # iptables -t nat -A OUTPUT -p tcp -m string \ --string "POST /addword?port=1001" --algo kmp \ -j DNAT --to-destination 127.0.0.1:3000
但它没有工作,我的iptables -nvL是干净的。
我试过了:
# iptables -t nat -A OUTPUT -p tcp -m string \ --string "POST /addword?port=1001" --algo kmp \ -o lo -j REDIRECT --to-ports 3000</code>
这也没有工作,我的iptables -nvL是干净的。
但是,使用以下命令阻止对http://api.lingualeo.com/addword请求:
# iptables -I OUTPUT -p tcp -m string \ --string "POST /addword?port=1001" --algo kmp -j DROP
按预期工作。
操作系统:archlinux x64