nftables のテーブル宣言の範囲外で ct ヘルパーオブジェクトを宣言します。

nftables のテーブル宣言の範囲外で ct ヘルパーオブジェクトを宣言します。

ct helper以下は、現在のオブジェクトの宣言方法の実際の例です。nftables ドキュメント

#!/usr/sbin/nft -f

add table filter_4 {
    # TODO: Can helper object be declared outside the scope of table declaration scope?
    # ct helper stateful object
    # "ftp-standard" is the name of this ct helper stateful object
    # "ftp" is the in-kernel name of the ct helper for ftp
    ct helper ftp-standard {
        type "ftp" protocol tcp;
    }
}

その後、オブジェクトがct helper使用されます。次のように:

add chain filter_4 new_out_4 {
    comment "New output IPv4 traffic"
}

# FTP (active and passive)
# Rule for initial ftp connection (control channel), setting ct helper stateful object to use
# "ftp-standard" is the name of the ct helper stateful object
add rule filter_4 new_out_4 tcp sport >1023 tcp dport 21 ct helper set "ftp-standard" accept

私が達成しようとする目的は、コレクションがct helper宣言される方法と同様の方法でテーブル外のオブジェクトを宣言する構文を理解することです。

テーブル宣言の範囲外でコレクションを宣言する方法の例

add set filter_4 multicast_proto { type inet_proto; comment "IPv4 multicast protocols"; }
add element ip filter_4 multicast_proto { udp, igmp }

同様に、次のオブジェクトを宣言したいと思いますct helper

# Table declaration
add table filter_4

# Declare ct helper separately
add ct helper ftp-standard {
    type "ftp" protocol tcp;
}

もちろんこれはうまくいきません。ct helperこのような\statementを追加する構文は何ですか?

ct helperテーブルにバインドする必要があるようです(本当ですか?)上記の例では、テーブル名を指定する必要があるかもしれません。

ベストアンサー1

構文は次のとおりです。nft(8):

CT助手

add ct helper [family] table name { type type protocol protocol ; [l3proto family ;] }
delete ct helper [family] table name
list ct helpers

あなたの場合は次のとおりです。

  • シェルでは、('適切な場合は正しいシェルエスケープの使用を含め、それ自体nftは関係ありません:引数を同じに解析しますが、別々に提供されます):

    nft add ct helper filter_4 ftp-standard '{ type "ftp" protocol tcp; }'
    
  • または、すでにnftコンテキストにある場合は、次のようにします。

    add ct helper filter_4 ftp-standard { type "ftp" protocol tcp; }
    

おすすめ記事