V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
jarell
V2EX  ›  问与答

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

  •  
  •   jarell · 2017-07-19 19:32:18 +08:00 · 1752 次点击
    这是一个创建于 2444 天前的主题,其中的信息可能已经有所发展或是发生改变。
    iptables -t nat -A PREROUTING -d 192.168.99.0/24 -p tcp -j REDIRECT --to-ports 1234
    多谢
    4 条回复    2022-08-24 23:40:39 +08:00
    jasontse
        1
    jasontse  
       2017-07-19 19:55:31 +08:00 via iPad
    nft add rule nat prerouting daddr 192.168.99.0/24 tcp redirect to 1234

    你试试看吧
    jarell
        2
    jarell  
    OP
       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
        3
    jarell  
    OP
       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
        4
    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
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3109 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:55 · PVG 20:55 · LAX 05:55 · JFK 08:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.