Debianbuster / sidルールファイルに--multiportオプションがあると、iptables-restoreは失敗します。

Debianbuster / sidルールファイルに--multiportオプションがあると、iptables-restoreは失敗します。

私の/etc/iptables/rule.v4ファイルには多くのルールが含まれています。以下は問題のある行です。

-A INPUT -p tcp -m multiport --dports 22 -j ACCEPT
-A INPUT -p udp -m multiport --dports 16384:32768 -j ACCEPT

これを試みると、iptables-restore次のエラーで失敗します。

root@rs-dal:/etc/iptables# iptables-restore rules.q
iptables-restore v1.8.2 (nf_tables): multiport needs `-p tcp', `-p udp', `-p udplite', `-p sctp' or `-p dccp'
Error occurred at line: 26
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
root@rs-dal:/etc/iptables# 

なぜ失敗したのですか? 、同じルールが正常に適用されましたDebian Jessie

以下のようにルールを変更したときも機能しました。

-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p udp --dport 16384:32768 -j ACCEPT

iptables -L以下のようにこのルールを確認し、正常に適用しました。

ACCEPT     udp  --  anywhere             anywhere             udp dpts:16384:32768
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh

現在有効な構文を持つルールはありますか?

以下は私のOSの詳細です。

root@rs-dal:/etc/iptables# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

ベストアンサー1

nftablesユーザーABが指摘したように、Busterが使用するものとの間には非互換の問題があります。復元するルールを保存する最善の方法iptablesは、互換性のあるバージョン間で復元することです。iptablesiptables-restore

問題のある行を削除してルールを復元します。

iptables-restore < rules.q

構成にルールを再度追加し、以下を保存します。

iptables -A INPUT -p tcp -m multiport --dports 22 -j ACCEPT
iptables-save > rules.q

それでは、もう一度回復してみてください。

iptables-restore < rules.q

iptables -Lすべてのルールが正しいことを確認するために使用されます。

おすすめ記事