QRadar (Q) で帯域幅を制限するための実用的なガイド

IBM® QRadar ® の帯域幅マネージャーは、 Linux カーネル内で提供される階層トークン・バケット (HTB) キューイング規則を利用します。 詳細またはより高度な使用法については、インターネット上には、以下のような内容と機能を記述するページが多数あります。

注: このテクニカル・ブログ記事は 現状のまま であり、追加の審査を行ったことはありません。

作業を開始する前に、まずbandwidthManagerCLI.shファイルを微調整して、buildcpath ロケーションを変更する必要があります。 bandwidthManagerCLI.sh ファイルを編集するには、 edit /opt/qradar/bin/bandwidthManagerCLI.shと入力します。 ファイルの 3 行目を変更して、/opt/qradar/systemd/bin/buildcpath を読み取ります。 ファイルを保存して閉じます。

帯域幅マネージャーのヘルプおよび使用法

以下のコード・スニペットは、帯域幅マネージャーの使用法をリストしています。

[root@m5arch06 ~]# /opt/qradar/bin/bandwidthManagerCLI.sh
usage: BandwidthManagerCLI -a <ACTION>
          -a,--action The desired action. Recognized Actions: help, add_class, add_egress_filter,
                      delete_class, delete_egress_filter
usage: add_class <OPTIONS>
          -i,--hostID    The managed host ID which uniquely identifies the host. You can optionally
                         use '-1' to indicate you wish this to be applied to all hosts in the deployment
          -n,--name      A user-friendly name for the new configuration
          -c,--classID   The desired class ID of the class to be added
          -d,--device    The device name (e.g. eth0) which this configuration will apply to. You can
                         optionally use '*' to indicate you wish to be applied to all devices
          -h,--hostname  The managed host host name. Can be used when you don't provide the host ID
          -k,--kbpsLimit The rate limit to be applied against the class in kilobytes/sec
          -p,--parentID  The parent ID for this class
          -q,--qdiscID   The desired queuing discipline ID of the egress filter to be added
usage: add_egress_filter <OPTIONS>
          -i,--hostID           The managed host ID which uniquely identifies the host. You can
                                optionally use '-1' to indicate you wish this to be applied to all hosts in the deployment
          -n,--name             A user-friendly name for the new configuration
          -P,--protocol         The protocol for the new configuration
          -d,--device           The device name (e.g. eth0) which this configuration will apply to.
                                You can optionally use '*' to indicate you wish to be applied to all devices
          -dc,--dstCIDR         [Optional] The destination CIDR for the egress filter
          -dport,--dstPort      [Optional] The destination port for the egress filter
          -dportm,--dstPortMask [Optional] The destination port mask for the egress filter. If not
                                provided, 0xffff will be used (meaning match only that port)
          -f,--filterID         The desired filter ID to be assigned to the new egress filter
          -fl,--flowID          The filter's target flow ID (which represents the minor ID of a
                                class or qdisc). Traffic matched by this filter with go to that location
          -fp,--filterPriority  The fitler's priority relative to others attached to the same parent
                                (lower number is higher priority)
          -h,--hostname         The managed host host name. Can be used when you don't provide the
                                host ID
          -ma,--matchAll        [Optional] If "true", the filter that is created will match *all*
                                incoming packets at its priority level.
          -p,--parentID         The parent ID for this egress filter
          -q,--qdiscID          The desired queuing discipline ID of the egress filter to be added
          -sc,--sourceCIDR      [Optional] The source CIDR for the egress filter
          -sport,--srcPort      [Optional] The source port for the egress filter
          -sportm,--srcPortMask [Optional] The source port mask for the egress filter. If not
                                provided, 0xffff will be used (meaning match only that port)
usage: delete_class <OPTIONS>
          -i,--hostID   The managed host ID which uniquely identifies the host. You can optionally
                        use '-1' to indicate you wish this to be applied to all hosts in the deployment
          -c,--classID  The class ID to class to delete
          -d,--device   The device name (e.g. eth0) of the configuration to be deleted
          -h,--hostname The managed host host name. Can be used when you don't provide the host ID
          -q,--qdiscID  The queuing discipline ID of the class you wish to delete
usage: delete_egress_filter <OPTIONS>
          -i,--hostID   The managed host ID which uniquely identifies the host. You can optionally
                        use '-1' to indicate you wish this to be applied to all hosts in the deployment
          -d,--device   The device name (e.g. eth0) of the configuration to be deleted
          -f,--filterID The filter ID of the filter to delete
          -h,--hostname The managed host host name. Can be used when you don't provide the host ID
[root@m5arch06 ~]#

用語

このキューイングの規則 または HTB を使用すると、使用されるトークンおよびバケットのプロパティーを定義できます。 (このメカニズムについて心配する必要はありません。)
クラス

帯域幅のチャンク (最小値と最大値) を定義します。 これらはツリー構造で配置されます。 例えば、 QRadar (Q) と他のアプリケーションとの間で共有される 10 M ビット・リンクがあるとします。 QRadar (Q) が 5 M ビット/秒を超えて使用しないようにして、リンクが飽和状態にならないようにする必要があります。 5 Mbit/sec に制限されているすべてのトラフィックのクラスを定義してから、PostgreSQL 複製が検索パフォーマンスに影響を与えないように、さらに細分化することができます。

フィルター

これらのクラスのそれぞれに配置されるネットワーク・トラフィックを選択します。 通常、IP/プロトコル/ポートの組み合わせによって実行されるフィルターは、非常に柔軟性があり、非常に細かな細分性を許容します。これは、単純な IP/プロトコル/ポートの組み合わせを使用し続きます。

クックブックの例

すべてのコマンドはコンソール上で実行されます。管理対象ホスト上で実行する必要はありません。 変更を適用するホストをbandwidthManagerCLI.shコマンド行に指定します。

例: ホストへの複製の速度を低下させます (すべてのポート 443 トラフィック - 暗号化されていない場合)

この例では、帯域幅を 10 Kbps に制限するクラスを作成します。 次に、そのクラスにマップするフィルターを作成します。 これらのフィルターを、ソース・ポート 443 (コンソールであるため) および、宛先 IP 192.0.2.0 (この場合は管理対象ホスト) に限定したいと考えています。 コンソールのホスト名は m5arch06 です。
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch06 -n SlowReplication -c 1 -q 30 -p 0 -k 10 -d eno1
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchHttps -d eno1 -dc 192.0.2.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -sport 443 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchHttps -d eno1 -dc 192.0.2.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -sport 443 -P tcp

これをテストするには、管理対象ホストで強制的に複製を実行し、完全なデータベース・ダンプを要求し、最終的に以下の結果が得られました。
….
  2750K .......... .......... .......... .......... ..........  4% 9.02K 1h45m
  2800K .......... .......... .......... .......... ..........  4% 9.68K 1h45m
  2850K .......... .......... .......... .......... ..........  4% 9.51K 1h45m
  2900K .......... .......... .......... .......... ..........  4% 8.14K 1h45m
  2950K .......... .......... .......... .......... ..........  5% 9.00K 1h45m
  3000K .......... .......... .......... .......... ..........  5% 9.00K 1h45m
  3050K .......... .......... .......... .......... ..........  5% 9.99K 1h44m
…..

レートは、約10 キロバイト/秒です (超えない)。

コンソールでスロットルが発生しているかどうかをテストおよび確認するには、セットアップしたクラスからの出力を確認します。

[root@m5arch06 ~]# tc -s class ls dev eno1 classid 30:1
class htb 30:1 root prio 1 rate 80000bit ceil 80000bit burst 1600b cburst 1600b
 Sent 8579563 bytes 7315 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 3p requeues 0
 lended: 4682 borrowed: 0 giants: 0
 tokens: -4730822 ctokens: -4730822

[root@m5arch06 ~]#

帯域幅ルールを除去するには、次のコマンドを入力します。

/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch06 -c 1 -q 30 -d eno1
注: 帯域幅ルールを削除しない場合、これらのフィルターおよびクラスはリブート後も保持され、 QRadar (Q) はパッチ間で引き続きそれらを尊重します。

例: コンソールと管理対象ホストの間のすべての帯域幅の制限

ここでは、コンソールの帯域幅をモニターし、以下のセットアップでモニターを実行します。

  • m5arch06 (198.51.100.0) はコンソールです
  • m5arch07 (192.0.2.0) は管理対象ホストです
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch06 -n SlowCommunicationToHost -c 1 -q 30 -p 0 -k 10 -d eno1

以下のコマンドを入力して、クラスおよびキューイングの規則に一致するフィルターを追加します。

/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchToIP -d eno1 -dc 192.0.2.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchToIP -d eno1 -dc 192.0.2.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -P tcp

管理対象ホスト上の帯域幅をスロットルする場合 (これらが適用される hostname および宛先 CIDR に対する変更に注意してください)、以下のコマンドを入力します。

/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch07 -n SlowCommunicationToHost -c 1 -q 30 -p 0 -k 10 -d eno1
以下のコマンドを入力して、クラスおよびキューイングの規則に一致するフィルターを追加します。
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch07 -n MatchToIP -d eno1 -dc 198.51.100.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch07 -n MatchToIP -d eno1 -dc 198.51.100.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -P tcp

最後に、コンソールと管理対象ホストの両方から削除するには、以下のコマンドを入力します。

/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch06 -c 1 -q 30 -d eno1

/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch07 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch07 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch07 -c 1 -q 30 -d eno1

例: 変更内容を有効にするために、SQLを介して変更を追加し、Mbeanをポッキングします (少し速く、よりスクリプト可能)

この例では、最初の例と同じ構成を使用していますが、帯域幅マネージャーがフレームワークを初期化し、すべての作業を実行するのを待機する代わりに、PostgreSQL に挿入します。

帯域幅マネージャの構成に関連する次の 2 つのテーブルがあります。
  • 帯域幅構成テーブルには、すべてのクラス/帯域幅情報が含まれています。
    qradar=# \d bandwidth_configuration
    Table "public.bandwidth_configuration"
         Column     |          Type          |                             Modifiers                             
    ----------------+------------------------+------------------------------------------------------------
     sequenceid     | bigint                 | not null default nextval('bandwidth_configuration_seq'::regclass)
     appname        | character varying(100) | not null
     mh_id          | bigint                 | not null
     device         | character varying(100) | not null
     qdisc_id       | integer                | not null
     class_id       | integer                | not null
     parent_id      | integer                | not null
     bandwidth_kbps | bigint                 | not null
     created_by     | character varying(100) |
    
  • bandwidth_egress_filter には、以下のすべてのフィルターが含まれています。
    qradar=# \d bandwidth_egress_filter
    Table "public.bandwidth_egress_filter"
         Column      |          Type          |                             Modifiers                             
    -----------------+------------------------+-----------------------------------------------------------
     sequenceid      | bigint                 | not null default nextval('bandwidth_egress_filter_seq'::regclass)
     appname         | character varying(100) | not null
     mh_id           | bigint                 | not null
     device          | character varying(100) | not null
     qdisc_id        | integer                | not null
     parent_id       | integer                | not null
     filter_id       | integer                | not null
     flow_id         | integer                | not null
     filter_priority | integer                | not null
     src_port        | integer                |
     src_port_mask   | integer                |
     src_cidr        | character varying(45)  |
     dst_port        | integer                |
     dst_port_mask   | integer                |
     dst_cidr        | character varying(45)  |
     match_all       | boolean                | not null default false
     created_by      | character varying(100) |
     protocol        | character varying(4)   |
    

例 1からの構成を使用して、以下のスニペットのような SQL を使用して終了します。

INSERT INTO bandwidth_configuration (appname, mh_id, device, qdisc_id, class_id, parent_id, bandwidth_kbps, created_by) VALUES ('SlowReplication', 53, 'eno1', 30, 1, 0, 10, 'SQL_Insert');
INSERT INTO bandwidth_egress_filter (appname, mh_id, device, qdisc_id, parent_id, filter_id, flow_id, filter_priority, src_port, src_port_mask, dst_cidr, created_by, protocol) VALUES ('MatchHttps', 53, 'eno1', 30, 0, 2, 1, 1, 443, 65535, '192.0.2.0/32', 'SQL_Insert', 'ip');
INSERT INTO bandwidth_egress_filter (appname, mh_id, device, qdisc_id, parent_id, filter_id, flow_id, filter_priority, src_port, src_port_mask, dst_cidr, created_by, protocol) VALUES ('MatchHttps', 53, 'eno1', 1, 0, 3, 3, 1, 443, 65535, '192.0.2.0/32', 'SQL_Insert', 'ip');

次に、Mbean をポークして、その構成をリフレッシュします。

[root@m5arch06 ~]# /opt/qradar/support/jmx.sh 7778 'com.q1labs.hostcontext.bm:application=hostcontext.hostcontext,type=BandwidthManager' reloadConfig

Invoking operation: reloadConfig ( )
Result: true

[root@m5arch06 ~]#

やった! クラスは戻ります。

[root@m5arch06 ~]# tc class ls dev eno1
class prio 1:1 parent 1: leaf 10:
class prio 1:2 parent 1: leaf 20:
class prio 1:3 parent 1: leaf 30:
class prio 1:4 parent 1: leaf 40:
class prio 1:5 parent 1: leaf 50:
class prio 1:6 parent 1: leaf 60:
class prio 1:7 parent 1: leaf 70:
class htb 30:1 root prio 1 rate 80000bit ceil 80000bit burst 1600b cburst 1600b
[root@m5arch06 ~]#

次に、データベース内の項目を削除し、再ロードします。

[root@m5arch06 ~]# psql -U qradar -c "DELETE from bandwidth_configuration"
DELETE 1
[root@m5arch06 ~]# psql -U qradar -c "DELETE from bandwidth_egress_filter"
DELETE 2
[root@m5arch06 ~]# /opt/qradar/support/jmx.sh 7778 'com.q1labs.hostcontext.bm:application=hostcontext.hostcontext,type=BandwidthManager' reloadConfig

Invoking operation: reloadConfig ( )
Result: true

[root@m5arch06 ~]#

やった! クラスは再び消えます。

[root@m5arch06 ~]# tc class ls dev eno1
class prio 1:1 parent 1: leaf 10:
class prio 1:2 parent 1: leaf 20:
class prio 1:3 parent 1: leaf 30:
class prio 1:4 parent 1: leaf 40:
class prio 1:5 parent 1: leaf 50:
class prio 1:6 parent 1: leaf 60:
class prio 1:7 parent 1: leaf 70:
[root@m5arch06 ~]#