iptables 请教

2019-04-08 10:58:03 +08:00
 shom
想用-m set ! --match-set 排除掉本地主机的数据包,但是匹配到数据后就不再匹配后边的规则了
是因为 RETURN ?有没有别的方法能够继续匹配后边的规则

# Generated by iptables-save v1.8.2 on Sat Apr 6 10:32:15 2019
*filter
:INPUT ACCEPT [146406:157587854]
:FORWARD ACCEPT [11322:1880055]
:OUTPUT ACCEPT [150794:155144149]
COMMIT
# Completed on Sat Apr 6 10:32:15 2019
# Generated by iptables-save v1.8.2 on Sat Apr 6 10:32:15 2019
*nat
:PREROUTING ACCEPT [250:18650]
:INPUT ACCEPT [59:4834]
:OUTPUT ACCEPT [97:6107]
:POSTROUTING ACCEPT [140:9893]
:proxy - [0:0]
-A PREROUTING -p tcp -j proxy
-A OUTPUT -p tcp -j proxy
-A proxy -d x.x.x.x -j RETURN
-A proxy -m set ! --match-set gfwlist dst -j RETURN
-A proxy -m set ! --match-set opendns dst -j RETURN
-A proxy -m set ! --match-set telegram dst -j RETURN
-A proxy -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-ports 1080
-A proxy -p tcp -m set --match-set telegram dst -j REDIRECT --to-ports 1080
-A proxy -p tcp -m set --match-set opendns dst -j REDIRECT --to-ports 1080

COMMIT
# Completed on Sat Apr 6 10:32:15 2019
581 次点击
所在节点    Linux
4 条回复
gesse
2019-04-08 11:22:41 +08:00
-A proxy -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-ports 1080
-A proxy -p tcp -m set --match-set telegram dst -j REDIRECT --to-ports 1080
-A proxy -p tcp -m set --match-set opendns dst -j REDIRECT --to-ports 1080

就这样谢就可以了。
gstqc
2019-04-08 11:28:15 +08:00
RETURN 表示跳过当前链的其他规则
好比如你一个函数,中间有个 return

! --match-set 一般配合 DROP REJECT 来做白名单,你这种场景不建议用
shom
2019-04-08 13:24:05 +08:00
@gstqc 多谢
OrochWang
2019-04-10 08:18:14 +08:00
那我也问一个。我想把本机内网 VPN 服务器的 1723 端口接收的 tcp/udp 包。发送到 openvpn 服务器的 1194 端口。做两层 vpn。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/552878

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX