要执行一些转发作业,我使用脚本添加自定义链。部分代码在这里(以根用户身份运行):
iptables -t nat -N v2ray_forwarder
iptables -t nat -I OUTPUT -j v2ray_forwarder
iptables -t nat -A v2ray_forwarder -p tcp -m set --match-set srv_ip dst -j RETURN
iptables -t nat -A v2ray_forwarder -d 0.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 10.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 127.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 192.168.0.0/16 -j RETURN
iptables -t nat -A v2ray_forwarder -p tcp -m set --match-set gfw_ip dst -j REDIRECT --to-port 1081
iptables -t nat -A v2ray_forwarder -p tcp -m set ! --match-set chn_ip dst -j REDIRECT --to-port 1081
代码运行良好,并且我确定软件包已正确中继。但是,在我点击sudo iptables -L
之后,它就会显示出来:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
在我的路由器(OpenWRT)上,iptables -L
始终显示所有链条都存在,但是在笔记本电脑上不起作用。有人可以告诉我为什么吗?
谢谢!