
私は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
が選択されているため、テーブルと衝突することはありませんfilter
。nftables入力チェーン(任意に と呼ぶc_in
)を優先度10で取得するので、iptables同じ場所にフックするINPUTチェーンは、固定の優先度0で優先されます。優先度を0のままにしておくと、チェーン間の順序は定義されません(iptables' またはnftables') が最初に実行されます。テーブル間でルールをドロップ/受け入れる場合は関係ありません。ここで行ったようにルールを分割する場合 (ただし、この特定のケースでは順序に特別なことは何もないので問題ありません)、およびルールを変更する場合や副作用のあるルールの場合 (たとえば、nftables セットまたはiptables仲間ipsetその後パケットをドロップすることは、最初にパケットをドロップする(その後何もしない)ことと同じではありません。
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
これはツールによるタイプミスまたは翻訳エラーのようです。
両方の世界の間で相互作用が必要な場合、「メッセージ」は次のようにして渡すことができます。マークこれは優先順位が重要なケースです。たとえば、ドロップアクションがnftablesルール管理上の理由から、代わりにこれを使用することができますが、iptables' フィルタ/INPUTが優先されますnftables' t c_in ここ:
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