iptables文字列ルールをnftablesに変換する

iptables文字列ルールをnftablesに変換する

ルールをiptableからnftableに移行しています。iptableからnftableへの移行

現在、複数のIPおよびポートブロックルールと文字列ベースのiptableルールがありますが、組み込みのiptable変換ルールを使用してルールをiptableからnftableに変換できましたが、iptableの文字列ベースのルールはnftablesに変換されます。コメントを書いてください。以下は翻訳されたnftableルールです。

    add rule ip filter INPUT tcp dport 1024-65535 counter accept
    add rule ip filter INPUT udp dport 1024-65535 counter accept
   65535 -j DROP
    # -t filter -A INPUT -p udp -m udp --dport 234 -m string --string abc.exe --algo bm --to 65535 -j DROP
    # -t filter -A INPUT -p udp -m udp --dport 234 -m string --string def.exe --algo bm --to 65535 -j DROP
    # -t filter -A INPUT -p udp -m udp --dport 234 -m string --string hij.exe --algo bm --to 65535 -j DROP
    add rule ip filter INPUT icmp type echo-reply ct state new,related,established  counter accept
    add rule ip filter INPUT icmp type echo-request ct state new,related,established  counter accept
    add rule ip filter INPUT icmp type destination-unreachable ct state new,related,established  counter accept
    add rule ip filter INPUT icmp type time-exceeded ct state new,related,established  counter accept

文字列ベースのiptableルールをnftableルールに変換する方法と、上記のように失敗した場合は、どのログを参照する必要があるかについてのヘルプが必要です。

ベストアンサー1

持つ今は何もない nftablesと同じ、これひも一致する項目は、現在サポートされていない拡張機能のリストにあります。これらのサポートされていないすべての拡張機能(およびおそらくサポートされている一部の拡張機能)は、次に変換されません。nftablesなぜならnftablesバイトコード(nft -a --debug=netlink list rulesetバイトコードを見てください)もカーネルにデフォルトで実装されていません。nftablesモジュールなので翻訳ツールは試してみません。

プロトコルについてもっと知っている場合は、次の文字列を見つけることができると予想できます。安定パケットの場所には利用可能な回避策があります。元の荷重表現そしてそこの例

そうでなければ混ぜることができますnftablesそしてiptables(含むiptables-nft)規則に応じて異なるテーブル名を使用する限りnftablesいいえiptables-nft(おそらく使用中です)。現在、段階的に廃止する予定はありません。iptables(少なくともiptables-nft次のようなさまざまなxtablesモジュールを使用して実装が完全に可能です。ひも)。

テーブルはここで選択されるため、tテーブルと競合しませんfilternftablesc_in優先順位が10の入力チェーン(任意に呼び出されます)を取得します。iptables同じ位置にぶら下がっているINPUTチェーンは、最初に固定された優先順位レベル0を持ちます。優先順位を0にしておくとチェーン(iptables'またはnftables') が最初に実行されます。テーブル間の削除/承認ルールは重要ではありません。本当に重要な場合は、ここのようにルールを分割するとき(ただし、この特定のケースでは順序が特別ではないため重要ではありません)、ルールや副作用のあるルールを変更するときです。nftables 置くまたはiptables仲間IPセットその後、パケットをドロップすることは、パケットを最初に削除してから何も削除しないこととは異なります。

nft add table ip t
nft add chain ip t c_in '{ type filter hook input priority 10; policy accept; }'

nft add rule ip t c_in tcp dport 1024-65535 counter accept
nft add rule ip t c_in udp dport 1024-65535 counter accept
nft add rule ip t c_in icmp type echo-reply ct state new,related,established  counter accept
nft add rule ip t c_in icmp type echo-request ct state new,related,established  counter accept
nft add rule ip t c_in icmp type destination-unreachable ct state new,related,established  counter accept
nft add rule ip t c_in icmp type time-exceeded ct state new,related,established  counter accept

iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string abc.exe --algo bm --to 65535 -j DROP
iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string def.exe --algo bm --to 65535 -j DROP
iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string hij.exe --algo bm --to 65535 -j DROP

申し訳ありません。どうすればいいのかわかりません。

   65535 -j DROP

これはツール部分のオタナ翻訳エラーのようです。

2 つの世界間の相互作用が必要な場合は、次のように「メッセージ」を渡すことができます。噴水。この場合、優先順位が重要です。たとえば、Put操作は次のようにのみ実行できる場合nftablesルール管理上の理由でこれを代わりに使用できます。iptables'フィルタ/入力が優先されます。nftablesここにはありません:

iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string abc.exe --algo bm --to 65535 -j MARK --set-mark 0xdead
iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string def.exe --algo bm --to 65535 -j MARK --set-mark 0xdead
iptables -t filter -A INPUT -p udp -m udp --dport 234 -m string --string hij.exe --algo bm --to 65535 -j MARK --set-mark 0xdead

そしてこれを挿入してくださいnftablesルールの前の段落ルールは...established...ここにあります。ひも最初のルールは次のとおりです。

nft add ip t c_in meta mark 0xdead drop

おすすめ記事