From: Akihiro MOTOKI Date: Tue, 6 May 2014 18:42:14 +0000 (+0900) Subject: iptables: Snapshot of iptables-extensions.8 X-Git-Url: http://git.osdn.net/view?p=linuxjm%2Fiptables.git;a=commitdiff_plain;h=8c91b1a461ff466007d73c376988ef71f4dd0bb7;hp=b5b64c291b766de77154dcd9409f00441fb9eb4a iptables: Snapshot of iptables-extensions.8 --- diff --git a/draft/man8/iptables-extensions.8 b/draft/man8/iptables-extensions.8 new file mode 100644 index 0000000..0a781cb --- /dev/null +++ b/draft/man8/iptables-extensions.8 @@ -0,0 +1,2283 @@ +.\"******************************************************************* +.\" +.\" This file was generated with po4a. Translate the source file. +.\" +.\"******************************************************************* +.\" +.\" Japanese Version Copyright (c) 2013 Akihiro MOTOKI +.\" all rights reserved. +.\" Translated 2013-04-08, Akihiro MOTOKI +.\" +.TH iptables\-extensions 8 "" "iptables 1.4.18" "iptables 1.4.18" +.SH 名前 +iptables\-extensions \(em 標準の iptables に含まれる拡張モジュールのリスト +.SH 書式 +\fBip6tables\fP [\fB\-m\fP \fIname\fP [\fImodule\-options\fP...]] [\fB\-j\fP \fItarget\-name\fP +[\fItarget\-options\fP...] +.PP +\fBiptables\fP [\fB\-m\fP \fIname\fP [\fImodule\-options\fP...]] [\fB\-j\fP \fItarget\-name\fP +[\fItarget\-options\fP...] +.SH マッチングの拡張 +iptables は拡張されたパケットマッチングモジュールを使うことができる。 使用するモジュールは \fB\-m\fP か \fB\-\-match\fP +の後ろにモジュール名に続けて指定する。 モジュール名の後ろには、 モジュールに応じて他のいろいろなコマンドラインオプションを指定することができる。 +複数の拡張マッチングモジュールを一行で指定することができる。 モジュールの指定より後ろで \fB\-h\fP か \fB\-\-help\fP を指定すると、 +モジュール固有のヘルプが表示される。 拡張マッチングモジュールはルールで指定された順序で評価される。 +.PP +.\" @MATCH@ +\fB\-p\fP か \fB\-\-protocol\fP が指定され、 かつ未知のオプションだけが指定されていた場合にのみ、 iptables +はプロトコルと同じ名前のマッチモジュールをロードし、 そのオプションを使えるようにしようとする。 +.SS addrtype +このモジュールは、 アドレス種別 (\fBaddress type\fP) に基づいてパケットマッチングを行う。 +アドレス種別はカーネルのネットワークスタック内で使われており、 アドレスはいくつかグループに分類される。 厳密なグループの定義は個々のレイヤ 3 +プロトコルに依存する。 +.PP +以下のアドレスタイプが利用できる。 +.TP +\fBUNSPEC\fP +アドレスを指定しない (つまりアドレス 0.0.0.0) +.TP +\fBUNICAST\fP +ユニキャストアドレス +.TP +\fBLOCAL\fP +ローカルアドレス +.TP +\fBBROADCAST\fP +ブロードキャストアドレス +.TP +\fBANYCAST\fP +エニーキャストアドレス +.TP +\fBMULTICAST\fP +マルチキャストアドレス +.TP +\fBBLACKHOLE\fP +ブラックホールアドレス +.TP +\fBUNREACHABLE\fP +到達できないアドレス +.TP +\fBPROHIBIT\fP +禁止されたアドレス +.TP +\fBTHROW\fP +要修正 +.TP +\fBNAT\fP +要修正 +.TP +\fBXRESOLVE\fP +.TP +[\fB!\fP] \fB\-\-src\-type\fP \fItype\fP +送信元アドレスが指定された種類の場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-dst\-type\fP \fItype\fP +宛先アドレスが指定された種類の場合にマッチする。 +.TP +\fB\-\-limit\-iface\-in\fP +アドレス種別のチェックをそのパケットが受信されたインターフェースに限定する。 このオプションは \fBPREROUTING\fP, \fBINPUT\fP, +\fBFORWARD\fP チェインでのみ利用できる。 \fB\-\-limit\-iface\-out\fP オプションと同時に指定することはできない。 +.TP +\fB\-\-limit\-iface\-out\fP +アドレス種別のチェックをそのパケットが出力されるインターフェースに限定する。 このオプションは \fBPOSTROUTING\fP, \fBOUTPUT\fP, +\fBFORWARD\fP チェインでのみ利用できる。 \fB\-\-limit\-iface\-in\fP オプションと同時に指定することはできない。 +.SS "ah (IPv6 の場合)" +このモジュールは IPsec パケットの認証ヘッダーのパラメータにマッチする。 +.TP +[\fB!\fP] \fB\-\-ahspi\fP \fIspi\fP[\fB:\fP\fIspi\fP] +SPI にマッチする。 +.TP +[\fB!\fP] \fB\-\-ahlen\fP \fIlength\fP +このヘッダーの全体の長さ (8進数)。 +.TP +\fB\-\-ahres\fP +予約フィールドが 0 で埋められている場合にマッチする。 +.SS "ah (IPv4 の場合)" +このモジュールは IPsec パケットの認証ヘッダー (AH) の SPI 値にマッチする。 +.TP +[\fB!\fP] \fB\-\-ahspi\fP \fIspi\fP[\fB:\fP\fIspi\fP] +.SS cluster +このモジュールを使うと、負荷分散装置なしで、ゲートウェイとバックエンドの負荷分散クラスターを配備できる。 +.PP +This match requires that all the nodes see the same packets. Thus, the +cluster match decides if this node has to handle a packet given the +following options: +.TP +\fB\-\-cluster\-total\-nodes\fP \fInum\fP +クラスターの合計ノード数を設定する。 +.TP +[\fB!\fP] \fB\-\-cluster\-local\-node\fP \fInum\fP +ローカルノードの数字の ID を設定する。 +.TP +[\fB!\fP] \fB\-\-cluster\-local\-nodemask\fP \fImask\fP +ローカルノードの ID マスクを設定する。 このオプションは \fB\-\-cluster\-local\-node\fP の代わりに使うことができる。 +.TP +\fB\-\-cluster\-hash\-seed\fP \fIvalue\fP +Jenkins ハッシュのシード値を設定する。 +.PP +例: +.IP +iptables \-A PREROUTING \-t mangle \-i eth1 \-m cluster \-\-cluster\-total\-nodes 2 +\-\-cluster\-local\-node 1 \-\-cluster\-hash\-seed 0xdeadbeef \-j MARK \-\-set\-mark +0xffff +.IP +iptables \-A PREROUTING \-t mangle \-i eth2 \-m cluster \-\-cluster\-total\-nodes 2 +\-\-cluster\-local\-node 1 \-\-cluster\-hash\-seed 0xdeadbeef \-j MARK \-\-set\-mark +0xffff +.IP +iptables \-A PREROUTING \-t mangle \-i eth1 \-m mark ! \-\-mark 0xffff \-j DROP +.IP +iptables \-A PREROUTING \-t mangle \-i eth2 \-m mark ! \-\-mark 0xffff \-j DROP +.PP +以下のコマンドで、 すべてのノードに同じパケットを届けることができる。 +.IP +ip maddr add 01:00:5e:00:01:01 dev eth1 +.IP +ip maddr add 01:00:5e:00:01:02 dev eth2 +.IP +arptables \-A OUTPUT \-o eth1 \-\-h\-length 6 \-j mangle \-\-mangle\-mac\-s +01:00:5e:00:01:01 +.IP +arptables \-A INPUT \-i eth1 \-\-h\-length 6 \-\-destination\-mac 01:00:5e:00:01:01 +\-j mangle \-\-mangle\-mac\-d 00:zz:yy:xx:5a:27 +.IP +arptables \-A OUTPUT \-o eth2 \-\-h\-length 6 \-j mangle \-\-mangle\-mac\-s +01:00:5e:00:01:02 +.IP +arptables \-A INPUT \-i eth2 \-\-h\-length 6 \-\-destination\-mac 01:00:5e:00:01:02 +\-j mangle \-\-mangle\-mac\-d 00:zz:yy:xx:5a:27 +.PP +TCP 接続の場合には、応答方向で受信した TCP ACK パケットが有効とマークされないようにするため、ピックアップ (pickup) +機能を無効する必要がある。 +.IP +echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose +.SS comment +ルールにコメント (最大 256 文字) を付けることができる。 +.TP +\fB\-\-comment\fP \fIcomment\fP +.TP +例: +iptables \-A INPUT \-i eth1 \-m comment \-\-comment "my local LAN" +.SS connbytes +一つのコネクション (もしくはそのコネクションを構成する 2 つのフローの一方) でそれまでに転送されたバイト数やパケット数、 +もしくはパケットあたりの平均バイト数にマッチする。 +.PP +カウンターは 64 ビットであり、したがってオーバーフローすることは考えられていない ;) +.PP +主な利用方法は、長時間存在するダウンロードを検出し、 これらに印を付けることで、 +トラフィック制御において艇優先帯域を使うようにスケジューリングできるようにすることである。 +.PP +コネクションあたりの転送バイト数は、 `conntrack \-L` 経由で見ることができ、 ctnetlink 経由でもアクセスすることもできる。 +.PP +アカウント情報を持っていないコネクションでは、 このマッチングは常に false を返す点に注意すること。 +"net.netfilter.nf_conntrack_acct" sysctl フラグで、 +\fB新規\fPコネクションでバイト数/パケット数の計測が行われるかが制御できる。 sysctl フラグが変更されても、 +既存のコネクションのアカウント情報は影響を受けない。 +.TP +[\fB!\fP] \fB\-\-connbytes\fP \fIfrom\fP[\fB:\fP\fIto\fP] +パケット数/バイト数/平均パケットサイズが FROM バイト/パケットより大きく TO バイト/パケットよりも小さいコネクションのパケットにマッチする。 +TO が省略した場合は FROM のみがチェックされる。 "!" を使うと、 この範囲にないパケットにマッチする。 +.TP +\fB\-\-connbytes\-dir\fP {\fBoriginal\fP|\fBreply\fP|\fBboth\fP} +どのパケットを計測するかを指定する +.TP +\fB\-\-connbytes\-mode\fP {\fBpackets\fP|\fBbytes\fP|\fBavgpkt\fP} +パケット総数、転送バイト数、これまでに受信した全パケットの平均サイズ (バイト単位) のどれをチェックするかを指定する。 "both" と +"avgpkt" を組み合わせて使った場合で、 (HTTP のように) データが (主に) 片方向でのみ転送される場合、 +平均パケットサイズは実際のデータパケットの約半分になる点に注意すること。 +.TP +例: +iptables .. \-m connbytes \-\-connbytes 10000:100000 \-\-connbytes\-dir both +\-\-connbytes\-mode bytes ... +.SS connlimit +一つのサーバーに対する、 一つのクライアント IP アドレス (またはクライアントアドレスブロック) からの同時接続数を制限することができる。 +.TP +\fB\-\-connlimit\-upto\fP \fIn\fP +既存の接続数が \fIn\fP 以下の場合にマッチする。 +.TP +\fB\-\-connlimit\-above\fP \fIn\fP +既存の接続数が \fIn\fP より多い場合にマッチする。 +.TP +\fB\-\-connlimit\-mask\fP \fIprefix_length\fP +プレフィックス長を使ってホストのグルーピングを行う。 IPv4 の場合には、プレフィックス長は 0 以上 32 以下の値でなければならない。 IPv6 +の場合には 0 以上 128 以下でなければならない。 指定しなかった場合、そのプロトコルで使われる最も長いプレフィックス長が使用される。 +.TP +\fB\-\-connlimit\-saddr\fP +送信元グループに対して制限を適用する。 これが \-\-connlimit\-daddr が指定されなかった場合のデフォルトである。 +.TP +\fB\-\-connlimit\-daddr\fP +宛先グループに対して制限を適用する。 +.PP +例: +.TP +# クライアントホストあたり 2 つの telnet 接続を許可する +iptables \-A INPUT \-p tcp \-\-syn \-\-dport 23 \-m connlimit \-\-connlimit\-above 2 +\-j REJECT +.TP +# 同じことのに行う別のマッチ方法 +iptables \-A INPUT \-p tcp \-\-syn \-\-dport 23 \-m connlimit \-\-connlimit\-upto 2 \-j +ACCEPT +.TP +# クラス C の送信元ネットワーク (ネットマスクが 24 ビット) あたりの同時 HTTP リクエスト数を 16 までに制限する +iptables \-p tcp \-\-syn \-\-dport 80 \-m connlimit \-\-connlimit\-above 16 +\-\-connlimit\-mask 24 \-j REJECT +.TP +# リンクローカルネットワークからの同時 HTTP リクエスト数を 16 までに制限する +(ipv6) ip6tables \-p tcp \-\-syn \-\-dport 80 \-s fe80::/64 \-m connlimit +\-\-connlimit\-above 16 \-\-connlimit\-mask 64 \-j REJECT +.TP +# 特定のホスト宛のコネクション数を制限する +ip6tables \-p tcp \-\-syn \-\-dport 49152:65535 \-d 2001:db8::1 \-m connlimit +\-\-connlimit\-above 100 \-j REJECT +.SS connmark +このモジュールはコネクションに関連づけられた netfilter の mark フィールドにマッチする (このフィールドは、 以下の +\fBCONNMARK\fP ターゲットで設定される)。 +.TP +[\fB!\fP] \fB\-\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP] +指定された mark 値を持つコネクションのパケットにマッチする (mask が指定されると、 比較の前に mask との論理積 (AND) +がとられる)。 +.SS conntrack +コネクション追跡 (connection tracking) と組み合わせて使用した場合に、 このモジュールを使うと、 +パケットやコネクションの追跡状態を知ることができる。 +.TP +[\fB!\fP] \fB\-\-ctstate\fP \fIstatelist\fP +\fIstatelist\fP はマッチするコネクション状態 (connection state) のリストで、 コンマ区切りで指定する。 +指定できる状態のリストは後述。 +.TP +[\fB!\fP] \fB\-\-ctproto\fP \fIl4proto\fP +指定されたレイヤ 4 のプロトコルにマッチする。 プロトコルは名前または数値で指定する。 +.TP +[\fB!\fP] \fB\-\-ctorigsrc\fP \fIaddress\fP[\fB/\fP\fImask\fP] +.TP +[\fB!\fP] \fB\-\-ctorigdst\fP \fIaddress\fP[\fB/\fP\fImask\fP] +.TP +[\fB!\fP] \fB\-\-ctreplsrc\fP \fIaddress\fP[\fB/\fP\fImask\fP] +.TP +[\fB!\fP] \fB\-\-ctrepldst\fP \fIaddress\fP[\fB/\fP\fImask\fP] +順方向/反対方向のコネクションの送信元/宛先アドレスにマッチする。 +.TP +[\fB!\fP] \fB\-\-ctorigsrcport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-ctorigdstport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-ctreplsrcport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-ctrepldstport\fP \fIport\fP[\fB:\fP\fIport\fP] +順方向/反対方向のコネクションの (TCP/UDPなどの) 送信元/宛先ポートアドレス、 もしくは GRE キーにマッチする。 +ポートの範囲指定はカーネル 2.6.38 以降でのみサポートされている。 +.TP +[\fB!\fP] \fB\-\-ctstatus\fP \fIstatelist\fP +\fIstatuslist\fP はマッチするコネクション状況 (connection status) のリストで、 コンマ区切りで指定する。 +指定できる状況のリストは後述。 +.TP +[\fB!\fP] \fB\-\-ctexpire\fP \fItime\fP[\fB:\fP\fItime\fP] +有効期間の残り秒数、 またはその範囲(両端を含む)にマッチする。 +.TP +\fB\-\-ctdir\fP {\fBORIGINAL\fP|\fBREPLY\fP} +指定した方向に流れるパケットにマッチする。 このフラグが全く指定されなかった場合、 両方向のパケットがマッチする。 +.PP +\fB\-\-ctstate\fP に指定できる状態は以下の通り。 +.TP +\fBINVALID\fP +そのパケットはどの既知のコネクションとも関連付けられていない。 +.TP +\fBNEW\fP +そのパケットが新しいコネクションを開始しようとしている。 もしくは、 両方の方向でパケットが観測されていないコネクションに関連付けられる。 +.TP +\fBESTABLISHED\fP +そのパケットが、 両方向のパケットが観測されたコネクションに関連付けられる。 +.TP +\fBRELATED\fP +そのパケットは、新しいコネクションを開始しようとしているが、 既存のコネクションと関連付けられる。 FTP データ転送や ICMP +エラーなどが該当する。 +.TP +\fBUNTRACKED\fP +そのパケットは全く追跡されていない。 この状態は、 raw テーブルで \-j CT \-\-notrack +を使って明示的にそのパケットを追跡しないようにしている場合に起こる。 +.TP +\fBSNAT\fP +元の送信元アドレスが応答の宛先アドレスと異なる場合にマッチする仮想的な状態。 +.TP +\fBDNAT\fP +元の宛先アドレスが応答の送信元アドレスと異なる場合にマッチする仮想的な状態。 +.PP +\fB\-\-ctstatus\fP に指定できる値は以下の通り。 +.TP +\fBNONE\fP +以下のいずれでもない。 +.TP +\fBEXPECTED\fP +期待通りのコネクションである (つまり conntrack のヘルパーがコネクションをセットアップした)。 +.TP +\fBSEEN_REPLY\fP +conntrack が両方の方向でパケットを観測済である。 +.TP +\fBASSURED\fP +conntrack エントリが early\-expired されることはない。 +.TP +\fBCONFIRMED\fP +Connection is confirmed: originating packet has left box. +.SS cpu +.TP +[\fB!\fP] \fB\-\-cpu\fP \fInumber\fP +このパケットを処理する CPU にマッチする。 CPU には 0 から NR_CPUS\-1 の番号が振られる。 +ネットワークトラフィックを複数のキューに分散させるために RPS (Remote Packet Steering) やマルチキュー NIC +と組み合わせて使用できる。 +.PP +例: +.PP +iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 80 \-m cpu \-\-cpu 0 \-j REDIRECT +\-\-to\-port 8080 +.PP +iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 80 \-m cpu \-\-cpu 1 \-j REDIRECT +\-\-to\-port 8081 +.PP +Linux 2.6.36 以降で利用可能。 +.SS dccp +.TP +[\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-dccp\-types\fP \fImask\fP +DCCP パケットタイプが \fImask\fP のいずれかであればマッチする。 \fImask\fP はカンマ区切りのパケットタイプのリストである。 +指定できるパケットタイプは \fBREQUEST RESPONSE DATA ACK DATAACK CLOSEREQ CLOSE RESET SYNC +SYNCACK INVALID\fP である。 +.TP +[\fB!\fP] \fB\-\-dccp\-option\fP \fInumber\fP +DCCP オプションが設定されている場合にマッチする。 +.SS devgroup +パケットの受信/送信インターフェースのデバイスグループにマッチする。 +.TP +[\fB!\fP] \fB\-\-src\-group\fP \fIname\fP +受信デバイスのデバイスグループにマッチする +.TP +[\fB!\fP] \fB\-\-dst\-group\fP \fIname\fP +送信デバイスのデバイスグループにマッチする +.SS dscp +このモジュールは、 IP ヘッダーの TOS フィールド内にある、 6 bit の DSCP フィールドにマッチする。 IETF では DSCP が +TOS に取って代わった。 +.TP +[\fB!\fP] \fB\-\-dscp\fP \fIvalue\fP +(10 進または 16 進の) 数値 [0\-63] にマッチする。 +.TP +[\fB!\fP] \fB\-\-dscp\-class\fP \fIclass\fP +DiffServ クラスにマッチする。 値は BE, EF, AFxx, CSx クラスのいずれかである。 対応する数値に変換される。 +.SS "dst (IPv6 の場合)" +このモジュールは宛先オプションヘッダーのパラメータにマッチする。 +.TP +[\fB!\fP] \fB\-\-dst\-len\fP \fIlength\fP +このヘッダーの全体の長さ (8進数)。 +.TP +\fB\-\-dst\-opts\fP \fItype\fP[\fB:\fP\fIlength\fP][\fB,\fP\fItype\fP[\fB:\fP\fIlength\fP]...] +数値のオプションタイプとオプションデータのオクテット単位の長さ。 +.SS ecn +IPv4/IPv6 と TCP ヘッダーの ECN ビットにマッチングを行う。 ECN とは RFC3168 で規定された Explicit +Congestion Notification (明示的な輻輳通知) 機構のことである。 +.TP +[\fB!\fP] \fB\-\-ecn\-tcp\-cwr\fP +TCP ECN CWR (Congestion Window Received) ビットがセットされている場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-ecn\-tcp\-ece\fP +TCP ECN ECE (ECN Echo) ビットがセットされている場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-ecn\-ip\-ect\fP \fInum\fP +特定の IPv4/IPv6 ECT (ECN\-Capable Transport) にマッチする。 `0' 以上 `3' +以下の値を指定しなければならない。 +.SS esp +このモジュールは IPsec パケットの ESP ヘッダーの SPI 値にマッチする。 +.TP +[\fB!\fP] \fB\-\-espspi\fP \fIspi\fP[\fB:\fP\fIspi\fP] +.SS "eui64 (IPv6 の場合)" +このモジュールは stateless の自動で設定された IPv6 アドレスの EUI\-64 の部分にマッチする。 Ethernet の送信元 MAC +アドレスに基づく EUI\-64 と IPv6 送信元アドレスの下位 64 ビットの比較が行われる。 ただし "Universal/Local" +ビットは比較されない。 このモジュールは他のリンク層フレームにはマッチしない。 このモジュールは \fBPREROUTING\fP, \fBINPUT\fP, +\fBFORWARD\fP チェインでのみ有効である。 +.SS "frag (IPv6 の場合)" +このモジュールはフラグメントヘッダーのパラメータにマッチする。 +.TP +[\fB!\fP] \fB\-\-fragid\fP \fIid\fP[\fB:\fP\fIid\fP] +指定された値もしくは範囲の ID にマッチする。 +.TP +[\fB!\fP] \fB\-\-fraglen\fP \fIlength\fP +このオプションはバージョン 2.6.10 以降のカーネルでは使用できない。 フラグメントヘッダー長は変化しないので、このオプションは意味を持たない。 +.TP +\fB\-\-fragres\fP +予約フィールドに 0 が入っている場合にマッチする。 +.TP +\fB\-\-fragfirst\fP +最初のフラグメントにマッチする。 +.TP +\fB\-\-fragmore\fP +さらにフラグメントが続く場合にマッチする。 +.TP +\fB\-\-fraglast\fP +最後のフラグメントの場合にマッチする。 +.SS hashlimit +\fBhashlimit\fP uses hash buckets to express a rate limiting match (like the +\fBlimit\fP match) for a group of connections using a \fBsingle\fP iptables +rule. Grouping can be done per\-hostgroup (source and/or destination address) +and/or per\-port. It gives you the ability to express "\fIN\fP packets per time +quantum per group" or "\fIN\fP bytes per seconds" (see below for some +examples). +.PP +hash limit オプション (\fB\-\-hashlimit\-upto\fP, \fB\-\-hashlimit\-above\fP) と +\fB\-\-hashlimit\-name\fP は必須である。 +.TP +\fB\-\-hashlimit\-upto\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP] +単位時間あたりの平均マッチ回数の最大値。 数値で指定され、 添字 `/second', `/minute', `/hour', `/day' +を付けることもできる。 デフォルトは 3/hour である。 +.TP +\fB\-\-hashlimit\-above\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP] +レートが指定された区間での \fIamount\fP より大きい場合にマッチする。 +.TP +\fB\-\-hashlimit\-burst\fP \fIamount\fP +パケットがマッチする回数の最大初期値: 上のオプションで指定した制限に達しなければ、 マッチするごとに、 この数値になるまで 1 個ずつ増やされる。 +デフォルトは 5 である。 バイトでのレート照合が要求された場合、 このオプションは指定レートを超過できるバイト数を規定する。 +このオプションを使用する際には注意が必要である \-\- エントリがタイムアウトで削除される際に、バースト値もリセットされる。 +.TP +\fB\-\-hashlimit\-mode\fP {\fBsrcip\fP|\fBsrcport\fP|\fBdstip\fP|\fBdstport\fP}\fB,\fP... +対象とする要素のカンマ区切りのリスト。 \-\-hashlimit\-mode オプションが指定されなかった場合、 hashlimit は limit +と同じ動作をするが、 ハッシュの管理を行うコストがかかる。 +.TP +\fB\-\-hashlimit\-srcmask\fP \fIprefix\fP +When \-\-hashlimit\-mode srcip is used, all source addresses encountered will +be grouped according to the given prefix length and the so\-created subnet +will be subject to hashlimit. \fIprefix\fP must be between (inclusive) 0 and +32. Note that \-\-hashlimit\-srcmask 0 is basically doing the same thing as not +specifying srcip for \-\-hashlimit\-mode, but is technically more expensive. +.TP +\fB\-\-hashlimit\-dstmask\fP \fIprefix\fP +Like \-\-hashlimit\-srcmask, but for destination addresses. +.TP +\fB\-\-hashlimit\-name\fP \fIfoo\fP +/proc/net/ipt_hashlimit/foo エントリの名前。 +.TP +\fB\-\-hashlimit\-htable\-size\fP \fIbuckets\fP +ハッシュテーブルのバケット数。 +.TP +\fB\-\-hashlimit\-htable\-max\fP \fIentries\fP +ハッシュの最大エントリ数。 +.TP +\fB\-\-hashlimit\-htable\-expire\fP \fImsec\fP +ハッシュエントリが何ミリ秒後に削除されるか。 +.TP +\fB\-\-hashlimit\-htable\-gcinterval\fP \fImsec\fP +ガベージコレクションの間隔 (ミリ秒)。 +.PP +例: +.TP +送信元ホストに対するマッチ +"192.168.0.0/16 の各ホストに対して 1000 パケット/秒" => \-s 192.168.0.0/16 +\-\-hashlimit\-mode srcip \-\-hashlimit\-upto 1000/sec +.TP +送信元ポートに対するマッチ +"192.168.1.1 の各サービスに対して 100 パケット/秒" => \-s 192.168.1.1 \-\-hashlimit\-mode +srcport \-\-hashlimit\-upto 100/sec +.TP +サブネットに対するマッチ +"10.0.0.0/8 内の /28 サブネット (アドレス 8 個のグループ) それぞれに対して 10000 パケット/秒" => \-s +10.0.0.8 \-\-hashlimit\-mask 28 \-\-hashlimit\-upto 10000/min +.TP +バイト/秒によるマッチ +"512kbyte/s を超過したフロー" => \-\-hashlimit\-mode srcip,dstip,srcport,dstport +\-\-hashlimit\-above 512kb/s +.TP +バイト/秒によるマッチ +"512kbyte/s を超過するとマッチするが、 1 メガバイトに達するまではマッチせず許可する" \-\-hashlimit\-mode dstip +\-\-hashlimit\-above 512kb/s \-\-hashlimit\-burst 1mb +.SS "hbh (IPv6 の場合)" +このモジュールは Hop\-by\-Hop オプションヘッダーのパラメータにマッチする。 +.TP +[\fB!\fP] \fB\-\-hbh\-len\fP \fIlength\fP +このヘッダーの全体の長さ (8進数)。 +.TP +\fB\-\-hbh\-opts\fP \fItype\fP[\fB:\fP\fIlength\fP][\fB,\fP\fItype\fP[\fB:\fP\fIlength\fP]...] +数値のオプションタイプとオプションデータのオクテット単位の長さ。 +.SS helper +このモジュールは、 指定されたコネクション追跡ヘルパーモジュールに 関連するパケットにマッチする。 +.TP +[\fB!\fP] \fB\-\-helper\fP \fIstring\fP +指定されたコネクション追跡ヘルパーモジュールに 関連するパケットにマッチする。 +.RS +.PP +デフォルトのポートを使った ftp\-セッションに関連するパケットでは、 string に "ftp" と書ける。 他のポートでは "\-ポート番号" +を値に付け加える。 すなわち "ftp\-2121" となる。 +.PP +他のコネクション追跡ヘルパーでも同じルールが適用される。 +.RE +.SS "hl (IPv6 の場合)" +このモジュールは IPv6 ヘッダーの Hop Limit フィールドにマッチする。 +.TP +[\fB!\fP] \fB\-\-hl\-eq\fP \fIvalue\fP +Hop Limit が \fIvalue\fP と同じ場合にマッチする。 +.TP +\fB\-\-hl\-lt\fP \fIvalue\fP +Hop Limit が \fIvalue\fP より小さい場合にマッチする。 +.TP +\fB\-\-hl\-gt\fP \fIvalue\fP +Hop Limit が \fIvalue\fP より大きい場合にマッチする。 +.SS "icmp (IPv4 の場合)" +この拡張は `\-\-protocol icmp' が指定された場合に使用でき、 以下のオプションが提供される: +.TP +[\fB!\fP] \fB\-\-icmp\-type\fP {\fItype\fP[\fB/\fP\fIcode\fP]|\fItypename\fP} +ICMP タイプを指定できる。 タイプ指定には、 数値の ICMP タイプ、 タイプ/コードの組、 または以下のコマンド で表示される ICMP +タイプ名を指定できる。 +.nf + iptables \-p icmp \-h +.fi +.SS "icmp6 (IPv6 の場合)" +これらの拡張は `\-\-protocol ipv6\-icmp' または `\-\-protocol icmpv6' が指定された場合に使用でき、 +以下のオプションが提供される: +.TP +[\fB!\fP] \fB\-\-icmpv6\-type\fP \fItype\fP[\fB/\fP\fIcode\fP]|\fItypename\fP +ICMPv6 タイプを指定できる。 タイプ指定には、 数値の ICMP \fItype\fP、 \fItype\fP と \fIcode\fP、 または以下のコマンド +で表示される ICMPv6 タイプ名を指定できる。 +.nf + ip6tables \-p ipv6\-icmp \-h +.fi +.SS iprange +このモジュールは指定された任意の範囲の IP アドレスにマッチする。 +.TP +[\fB!\fP] \fB\-\-src\-range\fP \fIfrom\fP[\fB\-\fP\fIto\fP] +指定された範囲の送信元 IP にマッチする。 +.TP +[\fB!\fP] \fB\-\-dst\-range\fP \fIfrom\fP[\fB\-\fP\fIto\fP] +指定された範囲の宛先 IP にマッチする。 +.SS "ipv6header (IPv6 の場合)" +このモジュールは IPv6 拡張ヘッダー、 上位レイヤのヘッダー、もしくはその両方にマッチする。 +.TP +\fB\-\-soft\fP +パケットが \fB\-\-header\fP で指定されたヘッダーの\fBいずれか\fPを含む場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-header\fP \fIheader\fP[\fB,\fP\fIheader\fP...] +Matches the packet which EXACTLY includes all specified headers. The headers +encapsulated with ESP header are out of scope. Possible \fIheader\fP types can +be: +.TP +\fBhop\fP|\fBhop\-by\-hop\fP +Hop\-by\-Hop オプションヘッダー +.TP +\fBdst\fP +宛先オプションヘッダー +.TP +\fBroute\fP +ルーティングヘッダー +.TP +\fBfrag\fP +フラグメントヘッダー +.TP +\fBauth\fP +認証ヘッダー (AH) +.TP +\fBesp\fP +ESP (Encapsulating Security Payload) ヘッダー +.TP +\fBnone\fP +No Next header which matches 59 in the 'Next Header field' of IPv6 header or +any IPv6 extension headers +.TP +\fBproto\fP +which matches any upper layer protocol header. A protocol name from +/etc/protocols and numeric value also allowed. The number 255 is equivalent +to \fBproto\fP. +.SS ipvs +IPVS コネクション属性にマッチする。 +.TP +[\fB!\fP] \fB\-\-ipvs\fP +IPVS コネクションに属すパケット +.TP +以下のオプションでは \-\-ipvs も暗黙のうちに指定される (否定の場合も含む) +.TP +[\fB!\fP] \fB\-\-vproto\fP \fIprotocol\fP +マッチする VIP プロトコル (数値か名前 (例えば "tcp") で指定する) +.TP +[\fB!\fP] \fB\-\-vaddr\fP \fIaddress\fP[\fB/\fP\fImask\fP] +マッチする VIP アドレス +.TP +[\fB!\fP] \fB\-\-vport\fP \fIport\fP +マッチする VIP プロトコル (数値か名前 (例えば \"http\") で指定する) +.TP +\fB\-\-vdir\fP {\fBORIGINAL\fP|\fBREPLY\fP} +パケットフローの方向 +.TP +[\fB!\fP] \fB\-\-vmethod\fP {\fBGATE\fP|\fBIPIP\fP|\fBMASQ\fP} +使用する IPVS の転送方法 +.TP +[\fB!\fP] \fB\-\-vportctl\fP \fIport\fP +マッチする制御用コネクションの VIP ポート (例えば FTP であれば 21) +.SS length +このモジュールは、 パケットのレイヤ 3 ペイロード (例えばレイヤ 4 パケット) の長さが、 指定された値、 または値の範囲にあればマッチする。 +.TP +[\fB!\fP] \fB\-\-length\fP \fIlength\fP[\fB:\fP\fIlength\fP] +.SS limit +このモジュールは、 トークンバケットフィルタを使って制限レートのマッチを行う。 この拡張を使ったルールは、指定された制限に達するまでマッチする。 +例えば、 このモジュールはログ記録を制限するために \fBLOG\fP ターゲットと組み合わせて使うことができる。 +.PP +xt_limit has no negation support \- you will have to use \-m hashlimit ! +\-\-hashlimit \fIrate\fP in this case whilst omitting \-\-hashlimit\-mode. +.TP +\fB\-\-limit\fP \fIrate\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP] +単位時間あたりの平均マッチ回数の最大値。 数値で指定され、 添字 `/second', `/minute', `/hour', `/day' +を付けることもできる。 デフォルトは 3/hour である。 +.TP +\fB\-\-limit\-burst\fP \fInumber\fP +パケットがマッチする回数の最大初期値: 上のオプションで指定した制限に達しなければ、 マッチするごとに、 この数値になるまで 1 個ずつ増やされる。 +デフォルトは 5 である。 +.SS mac +.TP +[\fB!\fP] \fB\-\-mac\-source\fP \fIaddress\fP +送信元 MAC アドレスにマッチする。 \fIaddress\fP は XX:XX:XX:XX:XX:XX と +いう形式でなければならない。 イーサーネットデバイスから入ってくるパケッ +トで、 \fBPREROUTING\fP, \fBFORWARD\fP, \fBINPUT\fP チェインに入るパケットにしか +意味がない。 +.SS mark +このモジュールはパケットに関連づけられた netfilter の mark フィールドにマッチする (このフィールドは、 以下の \fBMARK\fP +ターゲットで設定される)。 +.TP +[\fB!\fP] \fB\-\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP] +指定された符号なしの mark 値を持つパケットにマッチする (\fImask\fP が指定されると、 比較の前に \fImask\fP との論理積 (AND) +がとられる)。 +.SS "mh (IPv6 の場合)" +この拡張は `\-\-protocol ipv6\-mh' または `\-\-protocol mh' が指定された場合にロードされる。 +以下のオプションが提供される。 +.TP +[\fB!\fP] \fB\-\-mh\-type\fP \fItype\fP[\fB:\fP\fItype\fP] +Mobility Header (MH) タイプを指定できる。 タイプ指定には、 数値の MH タイプか、 以下のコマンドで表示される MH +タイプ名を指定できる。 +.nf + ip6tables \-p ipv6\-mh \-h +.fi +.SS multiport +このモジュールは送信元ポートや宛先ポートの集合にマッチする。 ポートは 15 個まで指定できる。 ポートの範囲指定 (port:port) は 2 +ポートとカウントされる。 このモジュールが使用できるのは \fB\-p tcp\fP か \fB\-p udp\fP と組み合わせた場合だけである。 +.TP +[\fB!\fP] \fB\-\-source\-ports\fP,\fB\-\-sports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]... +送信元ポートが指定されたポートのいずれにマッチする。 フラグ \fB\-\-sports\fP はこのオプションの便利な別名である。 +複数のポートやポート範囲がカンマ区切りで指定できる。 ポート範囲はコロン区切りで指定する。 したがって \fB53,1024:65535\fP はポート 53 +および 1024 から 65535 までの全ポートにマッチする。 +.TP +[\fB!\fP] \fB\-\-destination\-ports\fP,\fB\-\-dports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]... +宛先ポートが指定されたポートのうちのいずれかであればマッチする。 +フラグ \fB\-\-dports\fP は、 このオプションの便利な別名である。 +.TP +[\fB!\fP] \fB\-\-ports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]... +送信元ポートと宛先ポートの一方が指定されたポートのいずれか一つと等しければ、 マッチする。 +.SS nfacct +nfacct マッチングは iptable に拡張アカウンティング機構を提供する。 このマッチングモジュールはユーザー空間スタンドアロンユーティリティ +\fBnfacct\fP(8) と一緒に使う必要がある。 +.PP +以下のオプションだけがこのマッチングで使用できる。 +.TP +\fB\-\-nfacct\-name\fP \fIname\fP +このルールセットがマッチするトラフィック量を記録するのに使用する既存のオブジェクト名を指定する。 +.PP +この拡張を使用するには、アカウンティングオブジェクトを作成する必要があります。 +.IP +nfacct add http\-traffic +.PP +それから、iptables を使ってアカウンティングオブジェクトにトラフィックを関連付けます。 +.IP +iptables \-I INPUT \-p tcp \-\-sport 80 \-m nfacct \-\-nfacct\-name http\-traffic +.IP +iptables \-I OUTPUT \-p tcp \-\-dport 80 \-m nfacct \-\-nfacct\-name http\-traffic +.PP +そうすると、ルールにマッチしたトラフィック量をチェックできる。 +.IP +nfacct get http\-traffic +.IP +{ pkts = 00000000000000000156, bytes = 00000000000000151786 } = +http\-traffic; +.PP +\fBnfacct\fP(8) は http://www.netfilter.org もしくは git.netfilter.org リポジトリから入手できる。 +.SS osf +osf モジュールは受動的な OS (オペレーティングシステム) フィンガープリンティングを行う。 このモジュールは SYN +ビットがセットされたパケットのいくつかのデータ (Window Size, MSS, オプションとその順序, TTL, DF など) を比較する。 +.TP +[\fB!\fP] \fB\-\-genre\fP \fIstring\fP +受動的フィンガープリンティングでマッチさせるオペレーティングシステムのジャンル。 +.TP +\fB\-\-ttl\fP \fIlevel\fP +パケットに対して、オペレーティングシステムを判定するための追加の TTL チェックを行う。 \fIlevel\fP には以下の値のいずれを指定できる。 +.IP \(bu 4 +0 \- 本当の IP アドレスとフィンガープリント TTL の比較を行う。 一般に LAN で有効である。 +.IP \(bu 4 +1 \- IP ヘッダーの TTL がフィンガープリント TTL より小さいかチェックする。 グローバルにルーティング可能なアドレスで有効である。 +.IP \(bu 4 +2 \- TTL の比較を全く行わない。 +.TP +\fB\-\-log\fP \fIlevel\fP +判別したジャンルが期待するものと違う場合でもロギングするかどうか。 \fIlevel\fP には以下のいずれかを指定できる。 +.IP \(bu 4 +マッチしたシグネチャーと不明なシグネチャーをすべて記録する +.IP \(bu 4 +1 \- 最初にマッチしたもののみを記録する +.IP \(bu 4 +2 \- マッチした既知のシグネチャーをすべて記録する +.PP +syslog に以下のようなメッセージが記録される。 +.PP +Windows [2000:SP3:Windows XP Pro SP1, 2000 SP3]: 11.22.33.55:4024 \-> +11.22.33.44:139 hops=3 Linux [2.5\-2.6:] : 1.2.3.4:42624 \-> 1.2.3.5:22 +hops=4 +.PP +OS フィンガープリントは \fBnfnl_osf\fP プログラムを使ってロードできる。 ファイルからフィンガープリントをロードするには以下のようにする。 +.PP +\fBnfnl_osf \-f /usr/share/xtables/pf.os\fP +.PP +再度削除するには以下のようにする。 +.PP +\fBnfnl_osf \-f /usr/share/xtables/pf.os \-d\fP +.PP +フィンガープリントデータベースは http://www.openbsd.org/cgi\-bin/cvsweb/src/etc/pf.os +からダウンロードできる。 +.SS owner +このモジュールは、 ローカルで生成されたパケットに対して、 パケット生成者の様々な特性に対するマッチを行う。 このマッチは OUTPUT チェインか +POSTROUTING チェインでのみ有効である。 転送パケットはどのソケットとも関連付けられていない。 +カーネルスレッドからのパケットには対応するソケットがあるが、 通常ソケットの所有者はいない。 +.TP +[\fB!\fP] \fB\-\-uid\-owner\fP \fIusername\fP +.TP +[\fB!\fP] \fB\-\-uid\-owner\fP \fIuserid\fP[\fB\-\fP\fIuserid\fP] +そのパケットのソケットのファイル構造体が存在し、ソケットの所有者が指定されたユーザーの場合にマッチする。 数値の UID や UID +の範囲を指定することもできる。 +.TP +[\fB!\fP] \fB\-\-gid\-owner\fP \fIgroupname\fP +.TP +[\fB!\fP] \fB\-\-gid\-owner\fP \fIgroupid\fP[\fB\-\fP\fIgroupid\fP] +そのパケットのソケットのファイル構造体の所有者が指定されたグループの場合にマッチする。 数値の GID や GID の範囲を指定することもできる。 +.TP +[\fB!\fP] \fB\-\-socket\-exists\fP +パケットがソケットに関連付けられている場合にマッチする。 +.SS physdev +このモジュールは、 ブリッジデバイスのスレーブにされた、 ブリッジポートの入出力デバイスにマッチする。 このモジュールは、 ブリッジによる透過的な IP +ファイアウォールの基盤の一部であり、 カーネルバージョン 2.5.44 以降でのみ有効である。 +.TP +[\fB!\fP] \fB\-\-physdev\-in\fP \fIname\fP +パケットが受信されるブリッジのポート名 (\fBINPUT\fP, \fBFORWARD\fP, \fBPREROUTING\fP チェインに入るパケットのみ)。 +インターフェース名が "+" で終っている場合、 その名前で始まる任意のインターフェース名にマッチする。 +ブリッジデバイスを通して受け取られなかったパケットは、 \&'!' が指定されていない限り、 このオプションにマッチしない。 +.TP +[\fB!\fP] \fB\-\-physdev\-out\fP \fIname\fP +パケットを送信することになるブリッジのポート名 (\fBFORWARD\fP, \fBOUTPUT\fP, \fBPOSTROUTING\fP +チェインに入るパケットのみ)。 インターフェース名が "+" で終っている場合、 その名前で始まる任意のインターフェース名にマッチする。 \fBnat\fP +と \fBmangle\fP テーブルの \fBOUTPUT\fP チェインではブリッジの出力ポートにマッチさせることができないが、 \fBfilter\fP テーブルの +\fBOUPUT\fP チェインではマッチ可能である。 パケットがブリッジデバイスから送られなかった場合、 またはパケットの出力デバイスが不明であった場合は、 +\&'!' が指定されていない限り、 パケットはこのオプションにマッチしない。 +.TP +[\fB!\fP] \fB\-\-physdev\-is\-in\fP +パケットがブリッジインターフェースに入った場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-physdev\-is\-out\fP +パケットがブリッジインターフェースから出ようとした場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-physdev\-is\-bridged\fP +パケットがブリッジされることにより、 ルーティングされなかった場合にマッチする。 これは FORWARD, POSTROUTING +チェインにおいてのみ役立つ。 +.SS pkttype +このモジュールは、 リンク層のパケットタイプにマッチする。 +.TP +[\fB!\fP] \fB\-\-pkt\-type\fP {\fBunicast\fP|\fBbroadcast\fP|\fBmulticast\fP} +.SS policy +このモジュールはパケットを処理する IPsec が使用するポリシーにマッチする。 +.TP +\fB\-\-dir\fP {\fBin\fP|\fBout\fP} +復号 (decapsulation) に使用するポリシーにマッチするか、カプセル化 (encapsulation) +に使用するポリシーにマッチするかを指定する。 \fBin\fP はチェイン \fBPREROUTING, INPUT, FORWARD\fP で有効で、 +\fBout\fP はチェイン \fBPOSTROUTING, OUTPUT, FORWARD\fP で有効である。 +.TP +\fB\-\-pol\fP {\fBnone\fP|\fBipsec\fP} +パケットが IPsec 処理対象であればマッチする。 \fB\-\-pol none\fP は \fB\-\-strict\fP と一緒に使用できない。 +.TP +\fB\-\-strict\fP +ポリシーが正確にマッチするか、指定したポリシーがポリシーのいずれかのルールにマッチするかを指定する。 +.PP +それぞれのポリシー要素を定義するのに、以下のオプション (複数可) を使用することができる。 \fB\-\-strict\fP +が有効になっている場合、各要素につき少なくともオプションを一つ指定しなければならない。 +.TP +[\fB!\fP] \fB\-\-reqid\fP \fIid\fP +ポリシールールの reqid にマッチする。 reqid は \fBsetkey\fP(8) でレベルとして \fBunique:id\fP を使って指定できる。 +.TP +[\fB!\fP] \fB\-\-spi\fP \fIspi\fP +SA の SPI にマッチする。 +.TP +[\fB!\fP] \fB\-\-proto\fP {\fBah\fP|\fBesp\fP|\fBipcomp\fP} +カプセル化プロトコルにマッチする。 +.TP +[\fB!\fP] \fB\-\-mode\fP {\fBtunnel\fP|\fBtransport\fP} +カプセル化モードにマッチする。 +.TP +[\fB!\fP] \fB\-\-tunnel\-src\fP \fIaddr\fP[\fB/\fP\fImask\fP] +トンネルモード SA の送信元エンドポイントアドレスにマッチする。 \fB\-\-mode tunnel\fP との組み合わせでのみ有効。 +.TP +[\fB!\fP] \fB\-\-tunnel\-dst\fP \fIaddr\fP[\fB/\fP\fImask\fP] +トンネルモード SA の宛先エンドポイントアドレスにマッチする。 \fB\-\-mode tunnel\fP との組み合わせでのみ有効。 +.TP +\fB\-\-next\fP +ポリシー定義の次の要素から開始する。 \fB\-\-strict\fP との組み合わせでのみ使用できる。 +.SS quota +Implements network quotas by decrementing a byte counter with each +packet. The condition matches until the byte counter reaches zero. Behavior +is reversed with negation (i.e. the condition does not match until the byte +counter reaches zero). +.TP +[\fB!\fP] \fB\-\-quota\fP \fIbytes\fP +バイト単位のクォータ。 +.SS rateest +レート推測器 (rate estimator) は RATEEST ターゲットで収集された推定レートにマッチする。 bps/pps +の絶対値に対するマッチング、 2 つのレート推測器の比較、 2 つのレート推測器の差分に対するマッチングをサポートしている。 +.PP +.\" * Absolute: +利用可能なオプションが分かりやすいように、すべての可能な組み合わせを以下に示す。 +.IP \(bu 4 +\fBrateest\fP \fIoperator\fP \fBrateest\-bps\fP +.IP \(bu 4 +.\" * Absolute + Delta: +\fBrateest\fP \fIoperator\fP \fBrateest\-pps\fP +.IP \(bu 4 +(\fBrateest\fP minus \fBrateest\-bps1\fP) \fIoperator\fP \fBrateest\-bps2\fP +.IP \(bu 4 +.\" * Relative: +(\fBrateest\fP minus \fBrateest\-pps1\fP) \fIoperator\fP \fBrateest\-pps2\fP +.IP \(bu 4 +\fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest\-bps\fP(without rate!) +.IP \(bu 4 +.\" * Relative + Delta: +\fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest\-pps\fP(without rate!) +.IP \(bu 4 +(\fBrateest1\fP minus \fBrateest\-bps1\fP) \fIoperator\fP (\fBrateest2\fP minus +\fBrateest\-bps2\fP) +.IP \(bu 4 +(\fBrateest1\fP minus \fBrateest\-pps1\fP) \fIoperator\fP (\fBrateest2\fP minus +\fBrateest\-pps2\fP) +.TP +\fB\-\-rateest\-delta\fP +(絶対モードでも相対モードでも) 各レート推測器について、 レート推測器が推測したフローレートと BPS/PPS +オプションで指定された固定値の差分を計算する。 フローレートが指定された BPS/PPS よりも大きい場合、 負の値ではなく 0 が代わりに使用される。 +つまり "max(0, rateest#_rate \- rateest#_bps)" が使用される。 +.TP +[\fB!\fP] \fB\-\-rateest\-lt\fP +レートが指定されたレートかレート推測器のレートよりも低い場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-rateest\-gt\fP +レートが指定されたレートかレート推測器のレートよりも高い場合にマッチする。 +.TP +[\fB!\fP] \fB\-\-rateest\-eq\fP +レートが指定されたレートかレート推測器のレートと等しい場合にマッチする。 +.PP +いわゆる「絶対モード」では、使用できるレート推測器は一つだけであり、固定値に対する比較だけができる。一方、「相対モード」では、2 +つのレート推測器が使用でき、レート推測器どうしの比較ができる。 +.TP +\fB\-\-rateest\fP \fIname\fP +絶対モードで使用するレート推測器の名前 +.TP +\fB\-\-rateest1\fP \fIname\fP +.TP +\fB\-\-rateest2\fP \fIname\fP +相対モードで使用する 2 つレート推測器の名前 +.TP +\fB\-\-rateest\-bps\fP [\fIvalue\fP] +.TP +\fB\-\-rateest\-pps\fP [\fIvalue\fP] +.TP +\fB\-\-rateest\-bps1\fP [\fIvalue\fP] +.TP +\fB\-\-rateest\-bps2\fP [\fIvalue\fP] +.TP +\fB\-\-rateest\-pps1\fP [\fIvalue\fP] +.TP +\fB\-\-rateest\-pps2\fP [\fIvalue\fP] +レート推測器と指定した値を、秒間のバイト数またはパケット数で比較する。 どのオプションがどの場合に使用できるかは上の箇条書きのリストを見てほしい。 +単位を示す接尾辞を付けることができる。 bit, [kmgt]bit, [KMGT]ibit, Bps, [KMGT]Bps, [KMGT]iBps +が使用できる。 +.PP +例: この機能を、データコネクションの開始時に利用可能帯域に基づいて、 FTP サーバーからの出力データコネクションを 2 +つの回線に振り分けるのに使用する場合。 +.PP +# 出力レートを推定する +.PP +iptables \-t mangle \-A POSTROUTING \-o eth0 \-j RATEEST \-\-rateest\-name eth0 +\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s +.PP +iptables \-t mangle \-A POSTROUTING \-o ppp0 \-j RATEEST \-\-rateest\-name ppp0 +\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s +.PP +# 利用可能帯域に基づいてマーキングを行う +.PP +iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper +ftp \-m rateest \-\-rateest\-delta \-\-rateest1 eth0 \-\-rateest\-bps1 2.5mbit +\-\-rateest\-gt \-\-rateest2 ppp0 \-\-rateest\-bps2 2mbit \-j CONNMARK \-\-set\-mark 1 +.PP +iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper +ftp \-m rateest \-\-rateest\-delta \-\-rateest1 ppp0 \-\-rateest\-bps1 2mbit +\-\-rateest\-gt \-\-rateest2 eth0 \-\-rateest\-bps2 2.5mbit \-j CONNMARK \-\-set\-mark 2 +.PP +iptables \-t mangle \-A balance \-j CONNMARK \-\-restore\-mark +.SS "realm (IPv4 の場合)" +This matches the routing realm. Routing realms are used in complex routing +setups involving dynamic routing protocols like BGP. +.TP +[\fB!\fP] \fB\-\-realm\fP \fIvalue\fP[\fB/\fP\fImask\fP] +Matches a given realm number (and optionally mask). If not a number, value +can be a named realm from /etc/iproute2/rt_realms (mask can not be used in +that case). +.SS recent +IP アドレスのリストを動的に作成し、このリストに対するマッチングをいくつかの方法で行う。 +.PP +例えば、 あなたのファイアウォールの 139 番ポートに接続しようとした「悪ガキ」リストを作成し、 +そのアドレスからのこれ以降のすべてのパケットを「廃棄」する。 +.PP +\fB\-\-set\fP, \fB\-\-rcheck\fP, \fB\-\-update\fP, \fB\-\-remove\fP は同時に使用できない。 +.TP +\fB\-\-name\fP \fIname\fP +コマンドで使用するリストを指定する。名前が指定されなかった場合 \fBDEFAULT\fP が使用される。 +.TP +[\fB!\fP] \fB\-\-set\fP +リストにパケットの送信元アドレスを追加する。 その送信元アドレスがすでにリストにある場合は、既存のエントリーを更新する。 常に成功を返す (\fB!\fP +が指定されている場合は常に失敗を返す)。 +.TP +\fB\-\-rsource\fP +recent リストのテーブルの照合/保存で、各パケットの送信元アドレスを使う。 これがデフォルトである。 +.TP +\fB\-\-rdest\fP +recent リストのテーブルの照合/保存で、各パケットの宛先アドレスを使う。 +.TP +\fB\-\-mask\fPnetmask +この recent リストに適用するネットマスク。 +.TP +[\fB!\fP] \fB\-\-rcheck\fP +このパケットの送信元アドレスが現在リストに含まれるかをチェックする。 +.TP +[\fB!\fP] \fB\-\-update\fP +\fB\-\-rcheck\fP と同じだが、 このオプションではマッチした場合に "last seen" タイムスタンプを更新する。 +.TP +[\fB!\fP] \fB\-\-remove\fP +パケットの送信元アドレスが現在リストに含まれているかをチェックし、 含まれている場合、そのアドレスをリストから削除し、ルールは true を返す。 +アドレスが含まれない場合、false を返す。 +.TP +\fB\-\-seconds\fP \fIseconds\fP +このオプションは \fB\-\-rcheck\fP か \fB\-\-update\fP との組み合わせでのみ使用できる。 使用された場合、 +アドレスがリストに含まれ、かつそのアドレスが直近の指定された秒数以内に観測された場合にのみ、 マッチするようになる。 +.TP +\fB\-\-reap\fP +このオプションは \fB\-\-seconds\fP との組み合わせでのみ使用できる。 使用された場合、 最後に指定された秒数より古いエントリーを破棄する。 +.TP +\fB\-\-hitcount\fP \fIhits\fP +このオプションは \fB\-\-rcheck\fP か \fB\-\-update\fP との組み合わせて使用しなければならない。 使用された場合、 +アドレスがリストに含まれ、受信されたパケット数が指定した値以上の場合にのみマッチするようになる。 このオプションは \fB\-\-seconds\fP +と共に使用することもでき、 その場合は指定された時間内のヒット数に対して照合を行う。 hitcount パラメータの最大値は xt_recent +カーネルモードの "ip_pkt_list_tot" パラメータで規定される。 +このコマンドリストでこの値よりも大きな値を指定すると、そのルールは拒否される。 +.TP +\fB\-\-rttl\fP +このオプションは \fB\-\-rcheck\fP か \fB\-\-update\fP との組み合わせでのみ使用できる。 使用された場合、 +アドレスがリストに含まれ、かつ現在のパケットの TTL が \fB\-\-set\fP ルールにヒットしたパケットの TTL +にマッチする場合にのみマッチするようになる。 このオプションは、 +送信元アドレスを偽装する人が偽りのパケットを送信して、このモジュールを使ってあなたのサイトへの他のアクセスができないようにする DoS +攻撃がある場合などに役に立つかもしれない。 +.PP +例: +.IP +iptables \-A FORWARD \-m recent \-\-name badguy \-\-rcheck \-\-seconds 60 \-j DROP +.IP +iptables \-A FORWARD \-p tcp \-i eth0 \-\-dport 139 \-m recent \-\-name badguy \-\-set +\-j DROP +.PP +Steve の ipt_recent ウェブサイト (http://snowman.net/projects/ipt_recent/) +にも使用例がいくつかある。 +.PP +\fB/proc/net/xt_recent/*\fP は現在のアドレスのリストと各リストの各エントリーの情報である。 +.PP +\fB/proc/net/xt_recent/\fP の各ファイルは、読み出して現在のリストを確認することができる。 また、以下のコマンドを使って、 +これらのファイルに書き込んでリストを変更することができる。 +.TP +\fBecho +\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP +DEFAULT リストに \fIaddr\fP を追加する +.TP +\fBecho \-\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP +DEFAULT リストから \fIaddr\fP を削除する +.TP +\fBecho / >/proc/net/xt_recent/DEFAULT\fP +DEFAULT リストをフラッシュ (全エントリーを削除) する +.PP +モジュール自体もパラメーターを取り、デフォルトは以下の通りである。 +.TP +\fBip_list_tot\fP=\fI100\fP +テーブル単位の記録アドレス数。 +.TP +\fBip_pkt_list_tot\fP=\fI20\fP +アドレス単位の記録パケット数。 +.TP +\fBip_list_hash_size\fP=\fI0\fP +ハッシュテーブルサイズ。 0 は ip_list_tot に基づいて計算することを意味する。 デフォルトは 512。 +.TP +\fBip_list_perms\fP=\fI0644\fP +/proc/net/xt_recent/* ファイルのアクセス許可モード。 +.TP +\fBip_list_uid\fP=\fI0\fP +/proc/net/xt_recent/* ファイルの数値 ID での所有者。 +.TP +\fBip_list_gid\fP=\fI0\fP +/proc/net/xt_recent/* ファイルの数値 ID でのグループ所有者。 +.SS rpfilter +Performs a reverse path filter test on a packet. If a reply to the packet +would be sent via the same interface that the packet arrived on, the packet +will match. Note that, unlike the in\-kernel rp_filter, packets protected by +IPSec are not treated specially. Combine this match with the policy match +if you want this. Also, packets arriving via the loopback interface are +always permitted. This match can only be used in the PREROUTING chain of +the raw or mangle table. +.TP +\fB\-\-loose\fP +Used to specifiy that the reverse path filter test should match even if the +selected output device is not the expected one. +.TP +\fB\-\-validmark\fP +Also use the packets' nfmark value when performing the reverse path route +lookup. +.TP +\fB\-\-accept\-local\fP +This will permit packets arriving from the network with a source address +that is also assigned to the local machine. +.TP +\fB\-\-invert\fP +This will invert the sense of the match. Instead of matching packets that +passed the reverse path filter test, match those that have failed it. +.PP +Example to log and drop packets failing the reverse path filter test: + +iptables \-t raw \-N RPFILTER + +iptables \-t raw \-A RPFILTER \-m rpfilter \-j RETURN + +iptables \-t raw \-A RPFILTER \-m limit \-\-limit 10/minute \-j NFLOG +\-\-nflog\-prefix "rpfilter drop" + +iptables \-t raw \-A RPFILTER \-j DROP + +iptables \-t raw \-A PREROUTING \-j RPFILTER + +失敗したパケットをドロップするが、ロギングを行わない例 + +iptables \-t raw \-A RPFILTER \-m rpfilter \-\-invert \-j DROP +.SS "rt (IPv6 の場合)" +IPv6 ルーティングヘッダーに対してマッチする。 +.TP +[\fB!\fP] \fB\-\-rt\-type\fP \fItype\fP +指定したタイプ (数値) にマッチする。 +.TP +[\fB!\fP] \fB\-\-rt\-segsleft\fP \fInum\fP[\fB:\fP\fInum\fP] +`segments left' フィールド (範囲) にマッチする。 +.TP +[\fB!\fP] \fB\-\-rt\-len\fP \fIlength\fP +このヘッダーの長さにマッチする。 +.TP +\fB\-\-rt\-0\-res\fP +予約フィールド (type=0) にもマッチする。 +.TP +\fB\-\-rt\-0\-addrs\fP \fIaddr\fP[\fB,\fP\fIaddr\fP...] +type=0 のアドレス (リスト) にマッチする。 +.TP +\fB\-\-rt\-0\-not\-strict\fP +type=0 のアドレスのリストは厳密なリストではない。 +.SS sctp +.TP +[\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP] +.TP +[\fB!\fP] \fB\-\-chunk\-types\fP {\fBall\fP|\fBany\fP|\fBonly\fP} \fIchunktype\fP[\fB:\fP\fIflags\fP] [...] +大文字のフラグ文字はそのフラグがセットされている場合にマッチし、 小文字のフラグ文字はセットされていない場合にマッチすることを指示する。 + +チャンク種別: DATA INIT INIT_ACK SACK HEARTBEAT HEARTBEAT_ACK ABORT SHUTDOWN +SHUTDOWN_ACK ERROR COOKIE_ECHO COOKIE_ACK ECN_ECNE ECN_CWR SHUTDOWN_COMPLETE +ASCONF ASCONF_ACK FORWARD_TSN + +チャンク種別で利用可能なフラグ +.br +DATA I U B E i u b e +.br +ABORT T t +.br +SHUTDOWN_COMPLETE T t + +(小文字はフラグを「オフ」にすることを、大文字は「オン」にすることを意味する) +.P +例: + +iptables \-A INPUT \-p sctp \-\-dport 80 \-j DROP + +iptables \-A INPUT \-p sctp \-\-chunk\-types any DATA,INIT \-j DROP + +iptables \-A INPUT \-p sctp \-\-chunk\-types any DATA:Be \-j ACCEPT +.SS set +このモジュールは \fBipsec\fP(8) で定義できる IP 集合にマッチする。 +.TP +[\fB!\fP] \fB\-\-match\-set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP]... +where flags are the comma separated list of \fBsrc\fP and/or \fBdst\fP +specifications and there can be no more than six of them. Hence the command +.IP + iptables \-A FORWARD \-m set \-\-match\-set test src,dst +.IP +will match packets, for which (if the set type is ipportmap) the source +address and destination port pair can be found in the specified set. If the +set type of the specified set is single dimension (for example ipmap), then +the command will match packets for which the source address can be found in +the specified set. +.TP +\fB\-\-return\-\-nomatch\fP +If the \fB\-\-return\-\-nomatch\fP option is specified and the set type supports +the \fBnomatch\fP flag, then the matching is reversed: a match with an element +flagged with \fBnomatch\fP returns \fBtrue\fP, while a match with a plain element +returns \fBfalse\fP. +.PP +The option \fB\-\-match\-set\fP can be replaced by \fB\-\-set\fP if that does not clash +with an option of other extensions. +.PP +Use of \-m set requires that ipset kernel support is provided, which, for +standard kernels, is the case since Linux 2.6.39. +.SS socket +This matches if an open socket can be found by doing a socket lookup on the +packet. +.TP +\fB\-\-transparent\fP +非透過 (non\-transparent) ソケットを無視する。 +.SS state +"state" 拡張は "conntrack" モジュールのサブセットである。 "state" を使うと、 +パケットについてのコネクション追跡状態を参照できる。 +.TP +[\fB!\fP] \fB\-\-state\fP \fIstate\fP +Where state is a comma separated list of the connection states to +match. Only a subset of the states unterstood by "conntrack" are recognized: +\fBINVALID\fP, \fBESTABLISHED\fP, \fBNEW\fP, \fBRELATED\fP or \fBUNTRACKED\fP. For their +description, see the "conntrack" heading in this manpage. +.SS statistic +このモジュールは統計的な条件に基づいたパケットのマッチングを行う。 二つのモードがサポートされており、 \fB\-\-mode\fP オプションで設定できる。 +.PP +サポートされているオプション: +.TP +\fB\-\-mode\fP \fImode\fP +マッチングルールのマッチングモードを設定する。 サポートされているモードは \fBrandom\fP と \fBnth\fP である。 +.TP +[\fB!\fP] \fB\-\-probability\fP \fIp\fP +ランダムにパケットがマッチする確率を設定する。 \fBrandom\fP モードでのみ機能する。 \fIp\fP は 0.0 と 1.0 の範囲でなければならない。 +サポートされている粒度は 1/2147483648 である。 +.TP +[\fB!\fP] \fB\-\-every\fP \fIn\fP +n パケットに 1 つマッチする。 \fBnth\fP モードでのみ機能する (\fB\-\-packet\fP オプションも参照)。 +.TP +\fB\-\-packet\fP \fIp\fP +\fBnth\fP モードでカウンターの初期値を設定する (0 <= p <= n\-1, デフォルトは 0)。 +.SS string +このモジュールは、いくつかのパターンマッチ手法を用いて指定された文字列とのマッチを行う。 Linux カーネル 2.6.14 以上が必要である。 +.TP +\fB\-\-algo\fP {\fBbm\fP|\fBkmp\fP} +パターンマッチング手法を選択する (bm = Boyer\-Moore, kmp = Knuth\-Pratt\-Morris) +.TP +\fB\-\-from\fP \fIoffset\fP +マッチングの検索を開始するオフセットを設定する。 指定されなかった場合のデフォルトは 0 である。 +.TP +\fB\-\-to\fP \fIoffset\fP +検索を終了するオフセットを設定する。 バイト \fIoffset\fP\-1 (バイト番号は 0 から開始) が検索範囲の最終バイトとなる。 +指定されなかった場合、デフォルトはパケットサイズである。 +.TP +[\fB!\fP] \fB\-\-string\fP \fIpattern\fP +指定されたパターンにマッチする。 +.TP +[\fB!\fP] \fB\-\-hex\-string\fP \fIpattern\fP +指定された 16 進表記のパターンにマッチする。 +.SS tcp +これらの拡張は `\-\-protocol tcp' が指定され場合に使用できる。 以下のオプションが提供される: +.TP +[\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP] +送信元ポートまたはポート範囲の指定。 サービス名またはポート番号を指定できる。 \fIfirst\fP\fB:\fP\fIlast\fP という形式で、 2 +つの番号を含む範囲を指定することもできる。 最初のポートを省略した場合、 "0" を仮定する。 最後のポートを省略した場合、 "65535" +を仮定する。 最初のポートが最後のポートより大きい場合、 2 つは入れ換えられる。 フラグ \fB\-\-sport\fP は、 +このオプションの便利な別名である。 +.TP +[\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP] +宛先ポートまたはポート範囲の指定。 フラグ \fB\-\-dport\fP は、 このオプションの便利な別名である。 +.TP +[\fB!\fP] \fB\-\-tcp\-flags\fP \fImask\fP \fIcomp\fP +TCP フラグが指定されたものと等しい場合にマッチする。 第 1 引き数 \fImask\fP は評価対象とするフラグで、 コンマ区切りのリストである。 第 +2 引き数 \fIcomp\fP は必ず設定しなければならないフラグで、 コンマ区切りのリストである。 指定できるフラグは \fBSYN ACK FIN RST +URG PSH ALL NONE\fP である。 よって、 コマンド +.nf + iptables \-A FORWARD \-p tcp \-\-tcp\-flags SYN,ACK,FIN,RST SYN +.fi +は、 SYN フラグが設定され ACK, FIN, RST フラグが設定されていない パケットにのみマッチする。 +.TP +[\fB!\fP] \fB\-\-syn\fP +SYN ビットが設定され ACK, RST, FIN ビットがクリアされている TCP パケットにのみマッチする。 このようなパケットは TCP +コネクションの開始要求に使われる。 例えば、 あるインターフェースに入ってくるこのようなパケットをブロックすれば、 内側への TCP +コネクションは禁止されるが、 外側への TCP コネクションには影響しない。 これは \fB\-\-tcp\-flags SYN,RST,ACK,FIN +SYN\fP と等しい。 "\-\-syn" の前に "!" フラグ +を置くと、 SYN ビットがクリアされ ACK と RST ビットが設定されている +TCP パケットにのみマッチする。 +.TP +[\fB!\fP] \fB\-\-tcp\-option\fP \fInumber\fP +TCP オプションが設定されている場合にマッチする。 +.SS tcpmss +TCP ヘッダーの TCP MSS (maximum segment size) フィールドにマッチする。 TCP の SYN パケットか +SYN/ACK パケットに対してのみ利用できる。 MSS のネゴシエーションはコネクション開始時の TCP ハンドシェイク中だけだからである。 +.TP +[\fB!\fP] \fB\-\-mss\fP \fIvalue\fP[\fB:\fP\fIvalue\fP] +指定された TCP MSS 値か範囲にマッチする。 +.SS time +This matches if the packet arrival time/date is within a given range. All +options are optional, but are ANDed when specified. All times are +interpreted as UTC by default. +.TP +\fB\-\-datestart\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]] +.TP +\fB\-\-datestop\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]] +Only match during the given time, which must be in ISO 8601 "T" notation. +The possible time range is 1970\-01\-01T00:00:00 to 2038\-01\-19T04:17:07. +.IP +If \-\-datestart or \-\-datestop are not specified, it will default to +1970\-01\-01 and 2038\-01\-19, respectively. +.TP +\fB\-\-timestart\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP] +.TP +\fB\-\-timestop\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP] +Only match during the given daytime. The possible time range is 00:00:00 to +23:59:59. Leading zeroes are allowed (e.g. "06:03") and correctly +interpreted as base\-10. +.TP +[\fB!\fP] \fB\-\-monthdays\fP \fIday\fP[\fB,\fP\fIday\fP...] +Only match on the given days of the month. Possible values are \fB1\fP to +\fB31\fP. Note that specifying \fB31\fP will of course not match on months which +do not have a 31st day; the same goes for 28\- or 29\-day February. +.TP +[\fB!\fP] \fB\-\-weekdays\fP \fIday\fP[\fB,\fP\fIday\fP...] +Only match on the given weekdays. Possible values are \fBMon\fP, \fBTue\fP, +\fBWed\fP, \fBThu\fP, \fBFri\fP, \fBSat\fP, \fBSun\fP, or values from \fB1\fP to \fB7\fP, +respectively. You may also use two\-character variants (\fBMo\fP, \fBTu\fP, etc.). +.TP +\fB\-\-contiguous\fP +When \fB\-\-timestop\fP is smaller than \fB\-\-timestart\fP value, match this as a +single time period instead distinct intervals. See EXAMPLES. +.TP +\fB\-\-kerneltz\fP +Use the kernel timezone instead of UTC to determine whether a packet meets +the time regulations. +.PP +About kernel timezones: Linux keeps the system time in UTC, and always does +so. On boot, system time is initialized from a referential time +source. Where this time source has no timezone information, such as the x86 +CMOS RTC, UTC will be assumed. If the time source is however not in UTC, +userspace should provide the correct system time and timezone to the kernel +once it has the information. +.PP +Local time is a feature on top of the (timezone independent) system +time. Each process has its own idea of local time, specified via the TZ +environment variable. The kernel also has its own timezone offset +variable. The TZ userspace environment variable specifies how the UTC\-based +system time is displayed, e.g. when you run date(1), or what you see on your +desktop clock. The TZ string may resolve to different offsets at different +dates, which is what enables the automatic time\-jumping in userspace. when +DST changes. The kernel's timezone offset variable is used when it has to +convert between non\-UTC sources, such as FAT filesystems, to UTC (since the +latter is what the rest of the system uses). +.PP +The caveat with the kernel timezone is that Linux distributions may ignore +to set the kernel timezone, and instead only set the system time. Even if a +particular distribution does set the timezone at boot, it is usually does +not keep the kernel timezone offset \- which is what changes on DST \- up to +date. ntpd will not touch the kernel timezone, so running it will not +resolve the issue. As such, one may encounter a timezone that is always ++0000, or one that is wrong half of the time of the year. As such, \fBusing +\-\-kerneltz is highly discouraged.\fP +.PP +EXAMPLES. To match on weekends, use: +.IP +\-m time \-\-weekdays Sa,Su +.PP +Or, to match (once) on a national holiday block: +.IP +\-m time \-\-datestart 2007\-12\-24 \-\-datestop 2007\-12\-27 +.PP +Since the stop time is actually inclusive, you would need the following stop +time to not match the first second of the new day: +.IP +\-m time \-\-datestart 2007\-01\-01T17:00 \-\-datestop 2007\-01\-01T23:59:59 +.PP +During lunch hour: +.IP +\-m time \-\-timestart 12:30 \-\-timestop 13:30 +.PP +The fourth Friday in the month: +.IP +\-m time \-\-weekdays Fr \-\-monthdays 22,23,24,25,26,27,28 +.PP +(Note that this exploits a certain mathematical property. It is not possible +to say "fourth Thursday OR fourth Friday" in one rule. It is possible with +multiple rules, though.) +.PP +Matching across days might not do what is expected. For instance, +.IP +\-m time \-\-weekdays Mo \-\-timestart 23:00 \-\-timestop 01:00 Will match Monday, +for one hour from midnight to 1 a.m., and then again for another hour from +23:00 onwards. If this is unwanted, e.g. if you would like 'match for two +hours from Montay 23:00 onwards' you need to also specify the \-\-contiguous +option in the example above. +.SS tos +このモジュールは IPv4 ヘッダーの 8 ビットの Type of Service フィールド (すなわち上位ビットを含まれる) もしくは IPv6 +ヘッダーの (8 ビットの) Priority フィールドにマッチする。 +.TP +[\fB!\fP] \fB\-\-tos\fP \fIvalue\fP[\fB/\fP\fImask\fP] +指定された TOS マーク値を持つパケットにマッチする。 mask が指定されると、 比較の前に TOS マーク値との論理積 (AND) がとられる)。 +.TP +[\fB!\fP] \fB\-\-tos\fP \fIsymbol\fP +You can specify a symbolic name when using the tos match for IPv4. The list +of recognized TOS names can be obtained by calling iptables with \fB\-m tos +\-h\fP. Note that this implies a mask of 0x3F, i.e. all but the ECN bits. +.SS "ttl (IPv4 の場合)" +このモジュールは IP ヘッダーの time to live フィールドにマッチする。 +.TP +[\fB!\fP] \fB\-\-ttl\-eq\fP \fIttl\fP +指定された TTL 値にマッチする。 +.TP +\fB\-\-ttl\-gt\fP \fIttl\fP +TTL が指定された TTL 値より大きければマッチする。 +.TP +\fB\-\-ttl\-lt\fP \fIttl\fP +TTL が指定された TTL 値より小さければマッチする。 +.SS 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. +.TP +[\fB!\fP] \fB\-\-u32\fP \fItests\fP +The argument amounts to a program in a small language described below. +.IP +tests := location "=" value | tests "&&" location "=" value +.IP +value := range | value "," range +.IP +range := number | number ":" number +.PP +a single number, \fIn\fP, is interpreted the same as \fIn:n\fP. \fIn:m\fP is +interpreted as the range of numbers \fB>=n\fP and \fB<=m\fP. +.IP "" 4 +location := number | location operator number +.IP "" 4 +operator := "&" | "<<" | ">>" | "@" +.PP +The operators \fB&\fP, \fB<<\fP, \fB>>\fP and \fB&&\fP mean the same as +in C. The \fB=\fP is really a set membership operator and the value syntax +describes a set. The \fB@\fP operator is what allows moving to the next header +and is described further below. +.PP +There are currently some artificial implementation limits on the size of the +tests: +.IP " *" +no more than 10 of "\fB=\fP" (and 9 "\fB&&\fP"s) in the u32 argument +.IP " *" +no more than 10 ranges (and 9 commas) per value +.IP " *" +no more than 10 numbers (and 9 operators) per location +.PP +To describe the meaning of location, imagine the following machine that +interprets it. There are three registers: +.IP +A is of type \fBchar *\fP, initially the address of the IP header +.IP +B and C are unsigned 32 bit integers, initially zero +.PP +The instructions are: +.IP +number B = number; +.IP +C = (*(A+B)<<24) + (*(A+B+1)<<16) + (*(A+B+2)<<8) + +*(A+B+3) +.IP +&number C = C & number +.IP +<< number C = C << number +.IP +>> number C = C >> number +.IP +@number A = A + C; then do the instruction number +.PP +Any access of memory outside [skb\->data,skb\->end] causes the match +to fail. Otherwise the result of the computation is the final value of C. +.PP +Whitespace is allowed but not required in the tests. However, the characters +that do occur there are likely to require shell quoting, so it is a good +idea to enclose the arguments in quotes. +.PP +例: +.IP +match IP packets with total length >= 256 +.IP +The IP header contains a total length field in bytes 2\-3. +.IP +\-\-u32 "\fB0 & 0xFFFF = 0x100:0xFFFF\fP" +.IP +read bytes 0\-3 +.IP +AND that with 0xFFFF (giving bytes 2\-3), and test whether that is in the +range [0x100:0xFFFF] +.PP +Example: (more realistic, hence more complicated) +.IP +match ICMP packets with icmp type 0 +.IP +First test that it is an ICMP packet, true iff byte 9 (protocol) = 1 +.IP +\-\-u32 "\fB6 & 0xFF = 1 &&\fP ... +.IP +read bytes 6\-9, use \fB&\fP to throw away bytes 6\-8 and compare the result to +1. Next test that it is not a fragment. (If so, it might be part of such a +packet but we cannot always tell.) N.B.: This test is generally needed if +you want to match anything beyond the IP header. The last 6 bits of byte 6 +and all of byte 7 are 0 iff this is a complete packet (not a +fragment). Alternatively, you can allow first fragments by only testing the +last 5 bits of byte 6. +.IP +\&... \fB4 & 0x3FFF = 0 &&\fP ... +.IP +Last test: the first byte past the IP header (the type) is 0. This is where +we have to use the @syntax. The length of the IP header (IHL) in 32 bit +words is stored in the right half of byte 0 of the IP header itself. +.IP +\&... \fB0 >> 22 & 0x3C @ 0 >> 24 = 0\fP" +.IP +The first 0 means read bytes 0\-3, \fB>>22\fP means shift that 22 bits +to the right. Shifting 24 bits would give the first byte, so only 22 bits is +four times that plus a few more bits. \fB&3C\fP then eliminates the two extra +bits on the right and the first four bits of the first byte. For instance, +if IHL=5, then the IP header is 20 (4 x 5) bytes long. In this case, bytes +0\-1 are (in binary) xxxx0101 yyzzzzzz, \fB>>22\fP gives the 10 bit +value xxxx0101yy and \fB&3C\fP gives 010100. \fB@\fP means to use this number as a +new offset into the packet, and read four bytes starting from there. This is +the first 4 bytes of the ICMP payload, of which byte 0 is the ICMP +type. Therefore, we simply shift the value 24 to the right to throw out all +but the first byte and compare the result with 0. +.PP +例: +.IP +TCP payload bytes 8\-12 is any of 1, 2, 5 or 8 +.IP +First we test that the packet is a tcp packet (similar to ICMP). +.IP +\-\-u32 "\fB6 & 0xFF = 6 &&\fP ... +.IP +Next, test that it is not a fragment (same as above). +.IP +\&... \fB0 >> 22 & 0x3C @ 12 >> 26 & 0x3C @ 8 = 1,2,5,8\fP" +.IP +\fB0>>22&3C\fP as above computes the number of bytes in the IP +header. \fB@\fP makes this the new offset into the packet, which is the start +of the TCP header. The length of the TCP header (again in 32 bit words) is +the left half of byte 12 of the TCP header. The \fB12>>26&3C\fP +computes this length in bytes (similar to the IP header before). "@" makes +this the new offset, which is the start of the TCP payload. Finally, 8 reads +bytes 8\-12 of the payload and \fB=\fP checks whether the result is any of 1, 2, +5 or 8. +.SS udp +これらの拡張は `\-\-protocol udp' が指定された場合に利用できる。 以下のオプションが提供される。 +.TP +[\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP] +送信元ポートまたはポート範囲の指定。 詳細は TCP 拡張の \fB\-\-source\-port\fP オプションの説明を参照すること。 +.TP +[\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP] +宛先ポートまたはポート範囲の指定。 詳細は TCP 拡張の \fB\-\-destination\-port\fP オプションの説明を参照すること。 +.SS "unclean (IPv4 の場合)" +このモジュールにはオプションがないが、 おかしく正常でないように見えるパケットにマッチする。 これは実験的なものとして扱われている。 +.SH ターゲットの拡張 +.\" @TARGET@ +iptables は拡張ターゲットモジュールを使うことができる: 以下のものが、 標準的なディストリビューションに含まれている。 +.SS AUDIT +This target allows to create audit records for packets hitting the target. +It can be used to record accepted, dropped, and rejected packets. See +auditd(8) for additional details. +.TP +\fB\-\-type\fP {\fBaccept\fP|\fBdrop\fP|\fBreject\fP} +Set type of audit record. +.PP +例: +.IP +iptables \-N AUDIT_DROP +.IP +iptables \-A AUDIT_DROP \-j AUDIT \-\-type drop +.IP +iptables \-A AUDIT_DROP \-j DROP +.SS CHECKSUM +このターゲットは、 おかしいアプリケーションや古いアプリケーションに対する選択的な対処を可能にする。 mangle テーブルでのみ使用できる。 +.TP +\fB\-\-checksum\-fill\fP +Compute and fill in the checksum in a packet that lacks a checksum. This is +particularly useful, if you need to work around old applications such as +dhcp clients, that do not work well with checksum offloads, but don't want +to disable checksum offload in your device. +.SS CLASSIFY +This module allows you to set the skb\->priority value (and thus classify +the packet into a specific CBQ class). +.TP +\fB\-\-set\-class\fP \fImajor\fP\fB:\fP\fIminor\fP +Set the major and minor class value. The values are always interpreted as +hexadecimal even if no 0x prefix is given. +.SS "CLUSTERIP (IPv4 の場合)" +This module allows you to configure a simple cluster of nodes that share a +certain IP and MAC address without an explicit load balancer in front of +them. Connections are statically distributed between the nodes in this +cluster. +.TP +\fB\-\-new\fP +Create a new ClusterIP. You always have to set this on the first rule for a +given ClusterIP. +.TP +\fB\-\-hashmode\fP \fImode\fP +Specify the hashing mode. Has to be one of \fBsourceip\fP, +\fBsourceip\-sourceport\fP, \fBsourceip\-sourceport\-destport\fP. +.TP +\fB\-\-clustermac\fP \fImac\fP +Specify the ClusterIP MAC address. Has to be a link\-layer multicast address +.TP +\fB\-\-total\-nodes\fP \fInum\fP +Number of total nodes within this cluster. +.TP +\fB\-\-local\-node\fP \fInum\fP +Local node number within this cluster. +.TP +\fB\-\-hash\-init\fP \fIrnd\fP +Specify the random seed used for hash initialization. +.SS CONNMARK +このモジュールは、 コネクションに関連付けられた netfilter の mark 値を設定する。 mark は 32 ビット幅である。 +.TP +\fB\-\-set\-xmark\fP \fIvalue\fP[\fB/\fP\fImask\fP] +Zero out the bits given by \fImask\fP and XOR \fIvalue\fP into the ctmark. +.TP +\fB\-\-save\-mark\fP [\fB\-\-nfmask\fP \fInfmask\fP] [\fB\-\-ctmask\fP \fIctmask\fP] +Copy the packet mark (nfmark) to the connection mark (ctmark) using the +given masks. The new nfmark value is determined as follows: +.IP +ctmark = (ctmark & ~ctmask) ^ (nfmark & nfmask) +.IP +i.e. \fIctmask\fP defines what bits to clear and \fInfmask\fP what bits of the +nfmark to XOR into the ctmark. \fIctmask\fP and \fInfmask\fP default to +0xFFFFFFFF. +.TP +\fB\-\-restore\-mark\fP [\fB\-\-nfmask\fP \fInfmask\fP] [\fB\-\-ctmask\fP \fIctmask\fP] +Copy the connection mark (ctmark) to the packet mark (nfmark) using the +given masks. The new ctmark value is determined as follows: +.IP +nfmark = (nfmark & ~\fInfmask\fP) ^ (ctmark & \fIctmask\fP); +.IP +i.e. \fInfmask\fP defines what bits to clear and \fIctmask\fP what bits of the +ctmark to XOR into the nfmark. \fIctmask\fP and \fInfmask\fP default to +0xFFFFFFFF. +.IP +\fB\-\-restore\-mark\fP is only valid in the \fBmangle\fP table. +.PP +The following mnemonics are available for \fB\-\-set\-xmark\fP: +.TP +\fB\-\-and\-mark\fP \fIbits\fP +Binary AND the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark +0/\fP\fIinvbits\fP, where \fIinvbits\fP is the binary negation of \fIbits\fP.) +.TP +\fB\-\-or\-mark\fP \fIbits\fP +Binary OR the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP +\fIbits\fP\fB/\fP\fIbits\fP.) +.TP +\fB\-\-xor\-mark\fP \fIbits\fP +Binary XOR the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP +\fIbits\fP\fB/0\fP.) +.TP +\fB\-\-set\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP] +Set the connection mark. If a mask is specified then only those bits set in +the mask are modified. +.TP +\fB\-\-save\-mark\fP [\fB\-\-mask\fP \fImask\fP] +Copy the nfmark to the ctmark. If a mask is specified, only those bits are +copied. +.TP +\fB\-\-restore\-mark\fP [\fB\-\-mask\fP \fImask\fP] +ctmark を nfmark にコピーする。 mask が指定されると、 指定されたビットだけがコピーされる。 \fBmangle\fP +テーブルのみで有効である。 +.SS CONNSECMARK +This module copies security markings from packets to connections (if +unlabeled), and from connections back to packets (also only if unlabeled). +Typically used in conjunction with SECMARK, it is valid in the \fBsecurity\fP +table (for backwards compatibility with older kernels, it is also valid in +the \fBmangle\fP table). +.TP +\fB\-\-save\fP +If the packet has a security marking, copy it to the connection if the +connection is not marked. +.TP +\fB\-\-restore\fP +If the packet does not have a security marking, and the connection does, +copy the security marking from the connection to the packet. + +.SS CT +The CT target allows to set parameters for a packet or its associated +connection. The target attaches a "template" connection tracking entry to +the packet, which is then used by the conntrack core when initializing a new +ct entry. This target is thus only valid in the "raw" table. +.TP +\fB\-\-notrack\fP +Disables connection tracking for this packet. +.TP +\fB\-\-helper\fP \fIname\fP +Use the helper identified by \fIname\fP for the connection. This is more +flexible than loading the conntrack helper modules with preset ports. +.TP +\fB\-\-ctevents\fP \fIevent\fP[\fB,\fP...] +Only generate the specified conntrack events for this connection. Possible +event types are: \fBnew\fP, \fBrelated\fP, \fBdestroy\fP, \fBreply\fP, \fBassured\fP, +\fBprotoinfo\fP, \fBhelper\fP, \fBmark\fP (this refers to the ctmark, not nfmark), +\fBnatseqinfo\fP, \fBsecmark\fP (ctsecmark). +.TP +\fB\-\-expevents\fP \fIevent\fP[\fB,\fP...] +Only generate the specified expectation events for this connection. +Possible event types are: \fBnew\fP. +.TP +\fB\-\-zone\fP \fIid\fP +Assign this packet to zone \fIid\fP and only have lookups done in that zone. +By default, packets have zone 0. +.TP +\fB\-\-timeout\fP \fIname\fP +Use the timeout policy identified by \fIname\fP for the connection. This is +provides more flexible timeout policy definition than global timeout values +available at /proc/sys/net/netfilter/nf_conntrack_*_timeout_*. +.SS "DNAT (IPv4 の場合)" +このターゲットは \fBnat\fP テーブルの \fBPREROUTING\fP, \fBOUTPUT\fP チェイン、 これらのチェインから呼び出される +ユーザー定義チェインのみで有効である。 このターゲットはパケットの宛先アドレスを修正する (このコネクションの以降のパケットも修正して分からなく +(mangle) する)。 さらに、 ルールによるチェックを止めさせる。 このターゲットにはオプションが 1 種類ある: +.TP +\fB\-\-to\-destination\fP [\fIipaddr\fP[\fB\-\fP\fIipaddr\fP]][\fB:\fP\fIport\fP[\fB\-\fP\fIport\fP]] +1 つの新しい宛先 IP アドレス、 または IP アドレスの範囲が指定できる。 ポートの範囲を指定することもできる (これはルールで \fB\-p +tcp\fP または \fB\-p udp\fP を指定している場合にのみ有効)。 ポートの範囲が指定されていない場合、 宛先ポートは変更されない。 IP +アドレスが指定されなかった場合は、 宛先ポートだけが変更される。 + +2.6.10 以前のカーネルでは、 複数の \-\-to\-destination オプションを指定することができる。 これらのカーネルでは、 +アドレスの範囲指定や \-\-to\-destination オプションの複数回指定により 2 つ以上の宛先アドレスを指定した場合、 +それらのアドレスを使った単純なラウンドロビンによる負荷分散が行われる。 それ以降のカーネル (>= 2.6.11\-rc1) には複数の範囲を +NAT する機能は存在しない。 +.TP +\fB\-\-random\fP +If option \fB\-\-random\fP is used then port mapping will be randomized (kernel +>= 2.6.22). +.TP +\fB\-\-persistent\fP +Gives a client the same source\-/destination\-address for each connection. +This supersedes the SAME target. Support for persistent mappings is +available from 2.6.29\-rc2. +.SS DSCP +このターゲットは、 IPv4 パケットの TOS ヘッダーにある DSCP ビットの値の書き換えを可能にする。 これはパケットを操作するので、 +mangle テーブルでのみ使用できる。 +.TP +\fB\-\-set\-dscp\fP \fIvalue\fP +DSCP フィールドの数値を設定する (10 進または 16 進)。 +.TP +\fB\-\-set\-dscp\-class\fP \fIclass\fP +DSCP フィールドの DiffServ クラスを設定する。 +.SS "ECN (IPv4 の場合)" +このターゲットは ECN ブラックホール問題への対処を可能にする。 mangle テーブルでのみ使用できる。 +.TP +\fB\-\-ecn\-tcp\-remove\fP +TCP ヘッダーから全ての ECN ビット (訳注: ECE/CWR フラグ) を取り除く。 当然、 \fB\-p tcp\fP +オプションとの組合わせでのみ使用できる。 +.SS "HL (IPv6 の場合)" +This is used to modify the Hop Limit field in IPv6 header. The Hop Limit +field is similar to what is known as TTL value in IPv4. Setting or +incrementing the Hop Limit field can potentially be very dangerous, so it +should be avoided at any cost. This target is only valid in \fBmangle\fP table. +.PP +\fBDon't ever set or increment the value on packets that leave your local +network!\fP +.TP +\fB\-\-hl\-set\fP \fIvalue\fP +Set the Hop Limit to `value'. +.TP +\fB\-\-hl\-dec\fP \fIvalue\fP +Decrement the Hop Limit `value' times. +.TP +\fB\-\-hl\-inc\fP \fIvalue\fP +Increment the Hop Limit `value' times. +.SS HMARK +Like MARK, i.e. set the fwmark, but the mark is calculated from hashing +packet selector at choice. You have also to specify the mark range and, +optionally, the offset to start from. ICMP error messages are inspected and +used to calculate the hashing. +.PP +Existing options are: +.TP +\fB\-\-hmark\-tuple\fP tuple +Possible tuple members are: \fBsrc\fP meaning source address (IPv4, IPv6 +address), \fBdst\fP meaning destination address (IPv4, IPv6 address), \fBsport\fP +meaning source port (TCP, UDP, UDPlite, SCTP, DCCP), \fBdport\fP meaning +destination port (TCP, UDP, UDPlite, SCTP, DCCP), \fBspi\fP meaning Security +Parameter Index (AH, ESP), and \fBct\fP meaning the usage of the conntrack +tuple instead of the packet selectors. +.TP +\fB\-\-hmark\-mod\fP \fIvalue (must be > 0)\fP +Modulus for hash calculation (to limit the range of possible marks) +.TP +\fB\-\-hmark\-offset\fP \fIvalue\fP +Offset to start marks from. +.TP +For advanced usage, instead of using \-\-hmark\-tuple, you can specify custom +prefixes and masks: +.TP +\fB\-\-hmark\-src\-prefix\fP \fIcidr\fP +The source address mask in CIDR notation. +.TP +\fB\-\-hmark\-dst\-prefix\fP \fIcidr\fP +The destination address mask in CIDR notation. +.TP +\fB\-\-hmark\-sport\-mask\fP \fIvalue\fP +A 16 bit source port mask in hexadecimal. +.TP +\fB\-\-hmark\-dport\-mask\fP \fIvalue\fP +A 16 bit destination port mask in hexadecimal. +.TP +\fB\-\-hmark\-spi\-mask\fP \fIvalue\fP +A 32 bit field with spi mask. +.TP +\fB\-\-hmark\-proto\-mask\fP \fIvalue\fP +An 8 bit field with layer 4 protocol number. +.TP +\fB\-\-hmark\-rnd\fP \fIvalue\fP +A 32 bit random custom value to feed hash calculation. +.PP +\fIExamples:\fP +.PP +iptables \-t mangle \-A PREROUTING \-m conntrack \-\-ctstate NEW + \-j HMARK \-\-hmark\-tuple ct,src,dst,proto \-\-hmark\-offset 10000 +\-\-hmark\-mod 10 \-\-hmark\-rnd 0xfeedcafe +.PP +iptables \-t mangle \-A PREROUTING \-j HMARK \-\-hmark\-offset 10000 \-\-hmark\-tuple +src,dst,proto \-\-hmark\-mod 10 \-\-hmark\-rnd 0xdeafbeef +.SS IDLETIMER +This target can be used to identify when interfaces have been idle for a +certain period of time. Timers are identified by labels and are created +when a rule is set with a new label. The rules also take a timeout value +(in seconds) as an option. If more than one rule uses the same timer label, +the timer will be restarted whenever any of the rules get a hit. One entry +for each timer is created in sysfs. This attribute contains the timer +remaining for the timer to expire. The attributes are located under the +xt_idletimer class: +.PP +/sys/class/xt_idletimer/timers/