# CIDR query on ip range \[2nd try\]

**URL:** https://discuss.elastic.co/t/cidr-query-on-ip-range-2nd-try/141455
**Category:** Elasticsearch
**Created:** [July 25, 2018, 12:33am UTC](https://discuss.elastic.co/t/cidr-query-on-ip-range-2nd-try/141455 "2018-07-25T00:33:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)
#### Post date: [July 25, 2018, 12:33am UTC](https://discuss.elastic.co/t/cidr-query-on-ip-range-2nd-try/141455/1 "2018-07-25T00:33:25Z")

</div>

This is original question which I posted sometime back and was closed due to no reply or non-activity.

> [@CIDR query on ip\_range field not working](https://discuss.elastic.co/t/cidr-query-on-ip-range-field-not-working/133932):
>
> I have the following mapping "mappings": { "\_doc": { "properties": { "src\_ip": { "type": "ip\_range", "index": true }, "dst\_ip": { "type": "ip\_range", "index": true }, "src\_port": { "type": "integer\_range", "index": true }, "dst\_port": { "type": "integer\_range", "index": true }, "protocol": { "type" : "keyword" } } } …

Any pointers would help.

With "ip" data type, it does not accept ip address with prefix length(CIDR), but query allows CIDR style.  
With "ip\_range", it accepts ip address with prefix length(CIDR), but query does not CIDR style.

I need to map ip addresses of the form "10.1.1.1" or "10.1.1.0/16" from a json field to a elastic data type and want to support query in both forms 10.1.1.1 or 10.1.1.0/8 respectively.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 22, 2018, 12:40am UTC](https://discuss.elastic.co/t/cidr-query-on-ip-range-2nd-try/141455/2 "2018-08-22T00:40:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
