iptables: -m u32 関数を使用するときに「等しくない/一致」を表示する方法

iptables: -m u32 関数を使用するときに「等しくない/一致」を表示する方法

iptablesでは、-m u32 --u32を使用して、パケット内の特定のバイトをユーザー定義の値と一致させることができます。たとえば、

iptables -A 入力 -p tcp --dport 1000 -m u32 --u32 "xxxxxxxxxxx=0x11" -j 拒否

上記のiptablesルールにより、特定の1バイトの値がに等しい0x11。

私の質問は、「等しくない" または"合わない"? iptables のマニュアルページを見ると、!-m や -m! のような機能は存在しないようです。

答え1

コマンドラインの部分-m u32はモジュールを指定します。--u32部分は実際の式を指定します。つまり、必要な構文は次のようになります。

iptables -A INPUT -p tcp --dport 1000 -m u32 ! --u32 "xxxxxxxxxxx=0x11" -j REJECT

以下も参照iptables-extensions マニュアルページ以下抜粋:

 u32
       U32 tests whether quantities of up to 4 bytes extracted from a
       packet have specified values. The specification of what to
       extract is general enough to find data at given offsets from
       tcp headers or payloads.

       [!] --u32 tests
              The argument amounts to a program in a small language described below.

関連情報