Elasticsearch: Search for IP addresses with CIDR notation, in query_string

Created on 26 Aug 2014  路  22Comments  路  Source: elastic/elasticsearch

Today we can search for ranges IP addresses in fields with a query string query like this:
ip_address:[10.0.0.0 TO 10.255.255.255]

It would be great if we could do:
ip_address:10.0.0.0/8 or ip_address:10/8.

This is mostly useful in kibana, where all queries are sent at query_string queries. I understand that ip_range aggregation currently supports this. Would be nice in a QSQ :-)

:SearcSearch >feature help wanted

Most helpful comment

Can please someone tell me how to use it in Kibana? I use elasticsearch 5.6.4 and kibana 5.6.
We push netflows from a cisco asa to elasticsearch. I don't want to see the private networks. So I tried the query filter netflow.ipv4_src_addr: "172.16.0.0/16" but that doesn't work.

Edit:
I found the problem. The fields in the index were wrong. I had to reindex the index. I found the solution here: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html

Before I copied the data in the new index, I edited the mappings in the template for the fields netflow.ipv4_src_addr and netflow.ipv4_dst_addr to ip:

"netflow": {
          "dynamic": true,
          "properties": {
            "ipv4_src_addr": {
              "type": "ip"
            },
            "ipv4_dst_addr": {
              "type": "ip"
            },
            "xlate_src_addr_ipv4": {
              "type": "ip"
            },
            "xlate_dst_addr_ipv4": {
              "type": "ip"
            }
          }
        }

All 22 comments

+1 This would be a big help if we could search without the ranges.

+1

+1

+1

but
"must_not": [
{
"query_string": {
"query": "clientip:[10.44.0.0 TO 10.44.255.255]"
}
}
]
can not work well

+1

+1

+1

+1

+1

+1

+1

How to use this?

+1

+1

+1

+1

+1

+1

Closed via #14773

Our whole life is CIDR. +infinity!

Can please someone tell me how to use it in Kibana? I use elasticsearch 5.6.4 and kibana 5.6.
We push netflows from a cisco asa to elasticsearch. I don't want to see the private networks. So I tried the query filter netflow.ipv4_src_addr: "172.16.0.0/16" but that doesn't work.

Edit:
I found the problem. The fields in the index were wrong. I had to reindex the index. I found the solution here: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html

Before I copied the data in the new index, I edited the mappings in the template for the fields netflow.ipv4_src_addr and netflow.ipv4_dst_addr to ip:

"netflow": {
          "dynamic": true,
          "properties": {
            "ipv4_src_addr": {
              "type": "ip"
            },
            "ipv4_dst_addr": {
              "type": "ip"
            },
            "xlate_src_addr_ipv4": {
              "type": "ip"
            },
            "xlate_dst_addr_ipv4": {
              "type": "ip"
            }
          }
        }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

malpani picture malpani  路  3Comments

jpountz picture jpountz  路  3Comments

ttaranov picture ttaranov  路  3Comments

matthughes picture matthughes  路  3Comments

ppf2 picture ppf2  路  3Comments