BPF Settings for Port Mirroring
Specifying BPF filters for port mirroring will filter the traffic that is mirrored to your Mirror Destination Airwall Gateway. If you do not specify any filters, it will mirror all traffic.
Here are some sample BPF filters:
Filter Mirrored Traffic to Include/Exclude | BPF Filter Format | Description and Examples |
---|---|---|
Traffic using a specific IP protocol |
ip proto <protocol_to_include> ip proto not <protocol_to_exclude> |
Mirror only traffic using IP protocol of IPv6. Examples: Only include IPv6 traffic:
do not include IPv4
traffic:
|
All traffic on the specified host | host <host_ip> |
|
All traffic where the specified host is the source | src host <host_ip> |
|
Exclude IP traffic | no ip |
|
All traffic on the specified port | port <port_#> |
|
All traffic on the ports in the specified range | portrange <port1_#>-<port2_#> |
|
Specific data |
You can combine conditions to narrowly match specific protocols
like:
This
filter matches UDP traffic with a source or destination port of
10500 and the first 32 bits of the UDP payload is zero. This
matches HIP (control) protocol traffic excluding tunneled overlay traffic.Match HTTP packets where the payload starts with
GET:
1195725856
is GET represented as a 32-bit network byte order integer. |
|
Specific devices and protocols | Mirror traffic for devices on specific hosts and
ports:
|
|
Exclude high bandwidth service or known traffic | not (ip net <high_bandwidth_IP address> and tcp port <port_number> | Exclude all HTTPS traffic to/from
192.0.2.0/24:
Note: This
filter can also work well with rate limiting. By excluding the
known traffic (legitimate), you can mirror all of the other
traffic and capture a greater portion of the anomalies with a
small throughput and processing overhead. |
Port Mirroring BPF Reference
To create your own variations, here are the most useful BPF filter choices:
What to Filter
- IP host / network
- IPv6 host / network
- TCP / UDP port
Logical Operators
- and
- or
- not
Note: Identifiers that are also a keyword must be escaped using a backslash (\). For
example:
ip proto \icmp
. You can also refer to protocols by
number. See https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml as a reference. In this case, the above
would be ip proto 1
.For more information on BPF filters, refer to one of the BPF references available online, such as https://biot.com/capstats/bpf.html.