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

2017 年 7 月 19 日
 jarell
iptables -t nat -A PREROUTING -d 192.168.99.0/24 -p tcp -j REDIRECT --to-ports 1234
多谢
2494 次点击
所在节点    问与答
4 条回复
jasontse
2017 年 7 月 19 日
nft add rule nat prerouting daddr 192.168.99.0/24 tcp redirect to 1234

你试试看吧
jarell
2017 年 7 月 19 日
@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 年 7 月 19 日
# 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 年 8 月 24 日
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://study.congcong.us/t/376500

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

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

© 2021 V2EX