jarell
V2EX  ›  问与答

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

  •  
  •   jarell · Jul 19, 2017 · 2609 views
    This topic created in 3226 days ago, the information mentioned may be changed or developed.
    iptables -t nat -A PREROUTING -d 192.168.99.0/24 -p tcp -j REDIRECT --to-ports 1234
    多谢
    4 replies    2022-08-24 23:40:39 +08:00
    jasontse
        1
    jasontse  
       Jul 19, 2017 via iPad
    nft add rule nat prerouting daddr 192.168.99.0/24 tcp redirect to 1234

    你试试看吧
    jarell
        2
    jarell  
    OP
       Jul 19, 2017
    @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
       Jul 19, 2017
    # 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  
       Aug 24, 2022
    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
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1041 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:13 · PVG 03:13 · LAX 12:13 · JFK 15:13
    ♥ Do have faith in what you're doing.