Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network condition for matching IP network ranges #10743

Merged

Conversation

andrewkroh
Copy link
Member

The network condition checks if the field is in a certain IP network range.
Both IPv4 and IPv6 addresses are supported. The network range may be specified
using CIDR notation, like "192.0.2.0/24" or "2001:db8::/32", or by using one of
these named ranges:

  • loopback - Matches loopback addresses in the range of 127.0.0.0/8 or
    ::1/128.
  • unicast - Matches global unicast addresses defined in RFC 1122, RFC 4632,
    and RFC 4291 with the exception of the IPv4 broadcast address
    (255.255.255.255). This includes private address ranges.
  • multicast - Matches multicast addresses.
  • interface_local_multicast - Matches IPv6 interface-local multicast addresses.
  • link_local_unicast - Matches link-local unicast addresses.
  • link_local_multicast - Matches link-local multicast addresses.
  • private - Matches private address ranges defined in RFC 1918 (IPv4) and
    RFC 4193 (IPv6).
  • public - Matches addresses that are not loopback, unspecified, IPv4
    broadcast, link local unicast, link local multicast, interface local
    multicast, or private.
  • unspecified - Matches unspecified addresses (either the IPv4 address
    "0.0.0.0" or the IPv6 address "::").

Example

GUEST_NET: 172.16.0.0/16

processors:
  - add_fields:
      when:
        or:
          - source.ip: ${GUEST_NET}
          - destination.ip: ${GUEST_NET}
      fields:
        network.name: guest
      target: ""

The `network` condition checks if the field is in a certain IP network range.
Both IPv4 and IPv6 addresses are supported. The network range may be specified
using CIDR notation, like "192.0.2.0/24" or "2001:db8::/32", or by using one of
these named ranges:

- `loopback` - Matches loopback addresses in the range of `127.0.0.0/8` or
  `::1/128`.
- `unicast` - Matches global unicast addresses defined in RFC 1122, RFC 4632,
  and RFC 4291 with the exception of the IPv4 broadcast address
  (`255.255.255.255`). This includes private address ranges.
- `multicast` - Matches multicast addresses.
- `interface_local_multicast` - Matches IPv6 interface-local multicast addresses.
- `link_local_unicast` - Matches link-local unicast addresses.
- `link_local_multicast` - Matches link-local multicast addresses.
- `private` - Matches private address ranges defined in RFC 1918 (IPv4) and
  RFC 4193 (IPv6).
- `public` - Matches addresses that are not loopback, unspecified, IPv4
  broadcast, link local unicast, link local multicast, interface local
  multicast, or private.
- `unspecified` - Matches unspecified addresses (either the IPv4 address
  "0.0.0.0" or the IPv6 address "::").

Example

    GUEST_NET: 172.16.0.0/16

    processors:
      - add_fields:
          when:
            or:
              - source.ip: ${GUEST_NET}
              - destination.ip: ${GUEST_NET}
          fields:
            network.name: guest
          target: ""
Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tests are clear and show the usage, I've looked at the docs look good.

@andrewkroh andrewkroh merged commit e9183c2 into elastic:master Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants