iptables -Sとiptables -Lの違いは何ですか

iptables -Sとiptables -Lの違いは何ですか

ヘルプ情報はそれほど有益ではないようです。

--list    -L [chain [rulenum]]
      List the rules in a chain or all chains
--list-rules -S [chain [rulenum]]
      Print the rules in a chain or all chains

唯一の違いは単語の選択です:「リスト」と「印刷」。

マニュアルはもう少し詳しく説明していますが、まだ役に立ちません。

   -L, --list [chain]
          List all rules in the selected chain.  If no chain is selected, all chains are listed. Like every other iptables command, it applies to the specified table (filter  is  the  default),  so  NAT
          rules get listed by
           iptables -t nat -n -L
          Please note that it is often used with the -n option, in order to avoid long reverse DNS lookups.  It is legal to specify the -Z (zero) option as well, in which case the chain(s) will be atom‐
          ically listed and zeroed.  The exact output is affected by the other arguments given. The exact rules are suppressed until you use
           iptables -L -v

   -S, --list-rules [chain]
          Print all rules in the selected chain.  If no chain is selected, all chains are printed like iptables-save. Like every other iptables command, it applies to the specified table (filter is  the
          default).

私の考えでは、これは-S実際にはより冗長であり、パラメータを介して受け入れる正確なポートを印刷します--dports。ところで、なぜそうなのか? 「印刷」という単語が自動的に「リスト」よりも高いレベルの詳細を意味するとは思わないでしょうか?

ベストアンサー1

違いは出力形式にあります。この-Sオプションはフォーマットで生成されますiptables-save。これと一緒にiptables-apply再利用できますiptables-restore。 (man詳細については、該当するページのトピックを参照してください。)したがって、違いは次のように考えることができます。

  • -Lちなみに外に何があるのか​​知りたいです
  • -S再利用可能な出力用、機械解析用

-Sこのオプションがより詳細な情報を提供すると思われる場合は、iptablesより詳細な情報を提供する他のパラメータ学習と組み合わせる必要があります-L

おすすめ記事