QRadar 에서 대역폭을 제한하는 실용적인 안내서

IBM® QRadar ® 의 대역폭 관리자는 Linux 에서 제공되는 계층적 토큰 버켓 (HTB) 대기열 규칙을 이용합니다. 자세한 내용이나 고급 사용법은 인터넷에 다음과 같은 많은 페이지가 있으며 이 페이지에는 다음과 같은 내용이 포함되어 있다.

참고: 이 기술적 블로그 기사는 있는 그대로의 이며 추가 검증을 거치지 않았습니다.

시작하기 전에 먼저 bandwidthManagerCLI.sh 파일을 조정하여 buildcpath 위치를 변경해야 합니다. bandwidthManagerCLI.sh 파일을 편집하려면 edit /opt/qradar/bin/bandwidthManagerCLI.sh를 입력하십시오. 파일의 세 번째 행을 /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 과 다른 애플리케이션 간에 공유되는 10 Mbit 링크가 있습니다. QRadar 가 5Mbit/sec이상을 사용하지 않도록 하여 링크를 포화시키지 않도록 하려고 합니다. 5 Mbit/초로 제한되는 모든 트래픽에 대해 클래스를 정의한 다음, PostgreSQL 복제가 검색 성능에 영향을 주지 않도록 추가로 나눌 수 있습니다.

필터

이러한 각 수업에 배치되는 네트워크 트래픽을 선택하십시오. 일반적으로 IP/protocol/port 조합에 의해 수행되는 필터는 매우 유연하고 매우 미세한 세분성을 허용합니다. 이를 위해 간단한 IP/protocol/port 조합을 사용할 것이다.

Cookbook-예제

모든 명령은 콘솔에서 실행됩니다. 관리 호스트에서 실행할 필요가 없습니다. 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 Kbyte/초 이하이다.

콘솔에서 조절이 수행 중인지 여부를 테스트하고 확인하려면 다음과 같이 설정한 클래스의 출력을 확인하십시오.

[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 는 패치에서 계속해서 이를 준수합니다.

예제: 콘솔과 관리 호스트 간의 모든 대역폭 제한

콘솔 및 다음 설정에서 대역폭을 모니터할 것입니다.

  • 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및 poking Mbean을 통해 변경사항 추가 (약간 더 빠르고 더 많은 스크립트를 실행할 수 있음)

이 예제에서는 첫 번째 예제와 동일한 구성을 사용하지만, 대역폭 관리자가 프레임워크를 초기화하고 해당 작업을 모두 수행하기를 기다리는 대신 PostgreSQL 에 삽입합니다.

대역폭 관리자 구성과 관련된 두 가지 테이블이 있습니다.
  • 대역폭 구성 테이블에는 모든 클래스/대역폭 정보가 들어 있습니다.
    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 ~]#