请教一下这条 iptables 规则用 nftables 怎么写呢?

2017-07-19 19:32:18 +08:00
 jarell
iptables -t nat -A PREROUTING -d 192.168.99.0/24 -p tcp -j REDIRECT --to-ports 1234
多谢
1774 次点击
所在节点    问与答
4 条回复
jasontse
2017-07-19 19:55:31 +08:00
nft add rule nat prerouting daddr 192.168.99.0/24 tcp redirect to 1234

你试试看吧
jarell
2017-07-19 19:56:35 +08:00
@jasontse 显示下面这个
<cmdline>:1:25-29: Error: syntax error, unexpected daddr
add rule nat prerouting daddr 192.168.99.0/24 tcp redirect to 1234
^^^^^
jarell
2017-07-19 19:57:23 +08:00
# nft add rule nat prerouting ip daddr 192.168.99.0/24 tcp redirect to 1234
<cmdline>:1:54-61: Error: syntax error, unexpected redirect
add rule nat prerouting ip daddr 192.168.99.0/24 tcp redirect to 1234
gesse
2022-08-24 23:40:39 +08:00
root@xxx:~# iptables-translate -t nat -A PREROUTING -d 192.168.99.0/24 -p tcp -j REDIRECT --to-ports 1234
nft add rule ip nat PREROUTING ip protocol tcp ip daddr 192.168.99.0/24 counter redirect to :1234

PS: iptables-translate 需要 iptables 版本 1.8

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

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

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

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

© 2021 V2EX