# Ip range with subnet

**URL:** <https://discuss.elastic.co/t/ip-range-with-subnet/13508>\
**Category:** Elasticsearch\
**Created:** [September 8, 2013, 12:50pm UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508 "2013-09-08T12:50:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriele\_Angeli](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@Gabriele\_Angeli](https://discuss.elastic.co/u/Gabriele_Angeli)\
**Post date:** [September 8, 2013, 12:50pm UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508/1 "2013-09-08T12:50:47Z")

</div>

Hi guys,

```
i've a question for you. I know that in ES is possible make a search 

```

query with ip range,  
but is possible to put the subnet mask in this query?

Regards

Gabriele

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [September 9, 2013, 7:35am UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508/2 "2013-09-09T07:35:20Z")

</div>

The ip field type doesn't support a subnet, only just the ipv4 address.  
What do you want to do with storing also the subnet? If your goal is to  
store all ip addresses that fall into the specified subnet, then I think  
this would be a nice addition to the ip field type.

On 8 September 2013 14:50, Gabriele Angeli [g.angeli8214@gmail.com](mailto:g.angeli8214@gmail.com) wrote:

> Hi guys,
> 
> ```
> i've a question for you. I know that in ES is possible make a search
> 
> ```
> 
> query with ip range,  
> but is possible to put the subnet mask in this query?
> 
> Regards
> 
> Gabriele
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [September 9, 2013, 8:15am UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508/3 "2013-09-09T08:15:22Z")

</div>

Hi,

On Sun, Sep 8, 2013 at 2:50 PM, Gabriele Angeli [g.angeli8214@gmail.com](mailto:g.angeli8214@gmail.com)wrote:

> Hi guys,
> 
> ```
> i've a question for you. I know that in ES is possible make a search
> 
> ```
> 
> query with ip range,  
> but is possible to put the subnet mask in this query?

I'm not sure to get your question, would you like the query parser to  
translate an IP address and a subnet mask to a range query on ip addresses?

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tom\_Gullo](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Tom\_Gullo](https://discuss.elastic.co/u/Tom_Gullo)\
**Post date:** [September 10, 2013, 11:03am UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508/4 "2013-09-10T11:03:05Z")

</div>

You can convert the ip from 4 octets to a number and store the number.  
Then you can use a library (or write your own code) that gets the minimum  
value and maximum value out of a subnet. Then you do a range query with  
those numbers.

An IP address is just a number and a subnet is just a range.

On Sunday, September 8, 2013 8:50:47 AM UTC-4, Gabriele Angeli wrote:

> Hi guys,
> 
> ```
> i've a question for you. I know that in ES is possible make a search 
> 
> ```
> 
> query with ip range,  
> but is possible to put the subnet mask in this query?
> 
> Regards
> 
> Gabriele

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:17am UTC](https://discuss.elastic.co/t/ip-range-with-subnet/13508/5 "2017-07-06T02:17:21Z")

</div>


