Updated on 2026-10-27 GMT+08:00

Batch Creating Traffic Mirror Filter Rules

Function

This API is used to add inbound and outbound rules to a traffic mirror filter.

  • Inbound rules match the traffic received by a mirror source.

  • Outbound rules match the traffic sent by a mirror source.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    vpc:trafficMirrorFilterRules:create

    Write

    trafficMirrorFilter *

    -

    -

    -

    trafficMirrorFilterRule *

    -

URI

POST /v3/{project_id}/vpc/traffic-mirror-filters/{traffic_mirror_filter_id}/traffic-mirror-filter-rules/batch-create

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

ID of the project that a traffic mirror filter rule belongs to. For details about how to obtain a project ID, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

traffic_mirror_filter_id

Yes

String

Definition

ID of a traffic mirror filter.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

traffic_mirror_filter_rules

Yes

Array of BatchCreateTrafficMirrorFilterRuleOption objects

Definition

Traffic mirror filter rules.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 BatchCreateTrafficMirrorFilterRuleOption

Parameter

Mandatory

Type

Description

description

No

String

Definition

Description of a traffic mirror filter rule.

Constraints

The value can contain 0 to 255 characters and cannot contain angle brackets (< or >).

Range

N/A

Default Value

N/A

direction

Yes

String

Definition

Traffic direction.

Constraints

N/A

Range

  • ingress: inbound traffic

  • egress: outbound traffic

Default Value

N/A

protocol

Yes

String

Definition

Network protocol type supported by the mirrored traffic.

Constraints

N/A

Range

  • tcp: If you select TCP, you can customize the source and destination port ranges.

  • udp: If you select UDP, you can customize the source and destination port ranges.

  • icmp: If you set IP address version to IPv4 and select ICMP, all ports are specified for source and destination port ranges by default.

  • icmpv6: If you set IP address version to IPv6 and select ICMPv6, all ports are specified for source and destination port ranges by default.

  • all: If you select all, all network protocols are supported and all ports are specified for source and destination port ranges by default.

Default Value

N/A

ethertype

Yes

String

Definition

Address protocol version of the mirrored traffic.

Constraints

N/A

Range

  • IPv4

  • IPv6

Default Value

N/A

source_cidr_block

No

String

Definition

Source address of the mirrored traffic.

Constraints

N/A

Range

  • A single IP address: IP address/mask

    • Example IPv4 address: 192.168.10.10/32

    • Example IPv6 address: 2002:50::44/128

  • An IP address range in CIDR notation: IP address/mask

    • Example IPv4 CIDR block: 192.168.52.0/24

    • Example IPv6 CIDR block: 2407:c080:802:469::/64

  • All IP addresses

    • 0.0.0.0/0 represents all IPv4 addresses.

    • ::/0 represents all IPv6 addresses.

Default Value

N/A

destination_cidr_block

No

String

Definition

Destination address of the mirrored traffic.

Constraints

N/A

Range

  • A single IP address: IP address/mask

    • Example IPv4 address: 192.168.10.10/32

    • Example IPv6 address: 2002:50::44/128

  • An IP address range in CIDR notation: IP address/mask

    • Example IPv4 CIDR block: 192.168.52.0/24

    • Example IPv6 CIDR block: 2407:c080:802:469::/64

  • All IP addresses

    • 0.0.0.0/0 represents all IPv4 addresses.

    • ::/0 represents all IPv6 addresses.

Default Value

N/A

source_port_range

No

String

Definition

Source port range of the traffic.

Constraints

  • Use a hyphen (-) to connect the start port and the end port, for example, 22-23. The end port cannot be smaller than the start port.

  • If it is not specified or 1-65535 is specified, all ports are used.

Range

1 to 65535

Default Value

N/A

destination_port_range

No

String

Definition

Destination port range of the traffic.

Constraints

  • Use a hyphen (-) to connect the start port and the end port, for example, 22-23. The end port cannot be smaller than the start port.

  • If it is not specified or 1-65535 is specified, all ports are used.

Range

1 to 65535

Default Value

N/A

action

Yes

String

Definition

Whether to accept or reject the mirrored traffic that meets the traffic mirror filter.

Constraints

N/A

Range

  • accept: The traffic is accepted and will be mirrored to the mirror target.

  • reject: The traffic is rejected and will not be mirrored to the mirror target.

Default Value

N/A

priority

Yes

Integer

Definition

Priority of a traffic mirror filter rule. A smaller value indicates a higher priority.

Constraints

N/A

Range

1 to 65535

Default Value

N/A

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

traffic_mirror_filter_rules

Array of TrafficMirrorFilterRule objects

Definition

Response body for querying traffic mirror filter rules.

Range

N/A

request_id

String

Definition

Request ID.

Range

N/A

Table 5 TrafficMirrorFilterRule

Parameter

Type

Description

id

String

Definition:

ID of a traffic mirror filter rule.

Range:

N/A

project_id

String

Definition:

ID of the project that a traffic mirror filter rule belongs to.

Range:

N/A

description

String

Definition

Description of a traffic mirror filter rule.

Range

N/A

traffic_mirror_filter_id

String

Definition:

ID of the traffic mirror filter that a traffic mirror filter rule belongs to.

Range:

N/A

direction

String

Definition:

Traffic direction of a traffic mirror filter rule.

Range:

  • ingress: inbound traffic

  • egress: outbound traffic

source_cidr_block

String

Definition

Source of a traffic mirror filter rule.

Range

  • A single IP address: IP address/mask

    • Example IPv4 address: 192.168.10.10/32

    • Example IPv6 address: 2002:50::44/128

  • An IP address range in CIDR notation: IP address/mask

    • Example IPv4 CIDR block: 192.168.52.0/24

    • Example IPv6 CIDR block: 2407:c080:802:469::/64

  • All IP addresses

    • 0.0.0.0/0 represents all IPv4 addresses.

    • ::/0 represents all IPv6 addresses.

destination_cidr_block

String

Definition

Destination of a traffic mirror filter rule.

Range

  • A single IP address: IP address/mask

    • Example IPv4 address: 192.168.10.10/32

    • Example IPv6 address: 2002:50::44/128

  • An IP address range in CIDR notation: IP address/mask

    • Example IPv4 CIDR block: 192.168.52.0/24

    • Example IPv6 CIDR block: 2407:c080:802:469::/64

  • All IP addresses

    • 0.0.0.0/0 represents all IPv4 addresses.

    • ::/0 represents all IPv6 addresses.

source_port_range

String

Definition

Source port range of a traffic mirror filter rule.

Range

1 to 65535

destination_port_range

String

Definition

Destination port range of a traffic mirror filter rule.

Range

1 to 65535

ethertype

String

Definition

IP address version.

Range

  • IPv4

  • IPv6

protocol

String

Definition:

Network protocol type supported by traffic mirroring.

Range:

  • tcp : If you select TCP, you can customize the source and destination port ranges.

  • udp: If you select UDP, you can customize the source and destination port ranges.

  • icmp: If you set the IP address version to IPv4 and select ICMP, all ports are specified for source and destination port ranges by default.

  • icmpv6: If you set the IP address version to IPv6 and select ICMPv6, all ports are specified for source and destination port ranges by default.

  • all: If you select all, all network protocols are supported and all ports are specified for source and destination port ranges by default.

action

String

Definition:

Action of a traffic mirror filter rule.

Range:

  • accept

  • reject

priority

Integer

Definition:

Priority of a traffic mirror filter rule.

Range:

The value is from 1 to 65535. A smaller value indicates a higher priority.

created_at

String

Definition

Time when a traffic mirror filter rule was created.

Range

N/A

updated_at

String

Definition

Time when a traffic mirror filter rule was updated.

Range

N/A

Example Requests

Create two traffic mirror filter rules in batches. Set direction to ingress and protocol to ICMP.

POST http://{endpoint}/v3/{project_id}/vpc/traffic-mirror-filters/{traffic_mirror_filter_id}/traffic-mirror-filter-rules/batch-create

{
  "traffic_mirror_filter_rules" : [ {
    "ethertype" : "IPv4",
    "direction" : "ingress",
    "protocol" : "icmp",
    "source_cidr_block" : "192.168.0.0/24",
    "action" : "accept",
    "priority" : 29
  }, {
    "ethertype" : "IPv4",
    "direction" : "ingress",
    "protocol" : "icmp",
    "source_cidr_block" : "192.168.21.0/24",
    "action" : "reject",
    "priority" : 10
  } ]
}

Example Responses

Status code: 201

{
  "request_id" : "8dec5453-1690-4378-a976-40ba5e6d62ff",
  "traffic_mirror_filter_rules" : [ {
    "id" : "1be5f64b-49a1-427d-a49e-9619cfb0492c",
    "project_id" : "7365fcd452924e398ec4cc1fe39c0d12",
    "description" : "",
    "traffic_mirror_filter_id" : "417d7317-6c17-4428-a0f3-997d3e2293a0",
    "direction" : "ingress",
    "protocol" : "icmp",
    "ethertype" : "IPv4",
    "source_cidr_block" : "192.168.0.0/24",
    "action" : "accept",
    "priority" : 29,
    "type" : "eni",
    "created_at" : "2023-03-22T07:07:55.000+00:00",
    "updated_at" : "2023-03-22T07:07:55.000+00:00"
  }, {
    "id" : "4a97b166-ba05-01a9-b8fe-78af978d334b",
    "project_id" : "7365fcd452924e398ec4cc1fe39c0d12",
    "description" : "",
    "traffic_mirror_filter_id" : "417d7317-6c17-4428-a0f3-997d3e2293a0",
    "direction" : "ingress",
    "protocol" : "icmp",
    "ethertype" : "IPv4",
    "source_cidr_block" : "192.168.21.0/24",
    "action" : "reject",
    "priority" : 10,
    "type" : "eni",
    "created_at" : "2023-03-22T07:07:55.000+00:00",
    "updated_at" : "2023-03-22T07:07:55.000+00:00"
  } ]
}

Status Codes

Status Code

Description

201

Created

Error Codes

See Error Codes.