# Find IP in between two ranges

**URL:** <https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104>\
**Category:** Kibana\
**Created:** [May 26, 2021, 6:02pm UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104 "2021-05-26T18:02:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarthak\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarthak_mishra/32/82772_2.png) [@Sarthak\_Mishra](https://discuss.elastic.co/u/Sarthak_Mishra)\
**Post date:** [May 26, 2021, 6:02pm UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/1 "2021-05-26T18:02:20Z")

</div>

Hello Community,

I have two indexes. Index 1 contains a column of IP address. Index 2 contains 2 columns: the start subnet and end IP Address column. I want to find in which subnet range does the particular IP belong to? Please help.

![image](https://us1.discourse-cdn.com/elastic/original/3X/1/9/1932036f159cdd29d2724589cb3b6b1370e4edb5.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a9b72d9a9f50dc5f36c280ac6f271ff3665bb623.png)

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 27, 2021, 2:39am UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/2 "2021-05-27T02:39:35Z")

</div>

Can you give an example?  
Also provide your index mapping and data sample.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 27, 2021, 6:42am UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/3 "2021-05-27T06:42:55Z")

</div>

++ to providing more info.  
A screenshot of a spreadsheet isn't that helpful unfortunately.

---

<div class="post-metadata">

**Author:** ![Sarthak\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarthak_mishra/32/82772_2.png) [@Sarthak\_Mishra](https://discuss.elastic.co/u/Sarthak_Mishra)\
**Post date:** [May 31, 2021, 9:28am UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/4 "2021-05-31T09:28:04Z")

</div>

example: say ip address 10.127.9.55 from my second excel photo belongs to which range.  
there are 9 ranges in my first excel sheet photo i.e start ip address to end ip address.  
so the answer i expect is that this ip belongs to the 10.127.9.1(start ip) to 10.127.9.255(end ip) range

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [June 1, 2021, 1:53am UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/5 "2021-06-01T01:53:34Z")

</div>

How many ranges you have?  
one option is to create a scripted field and check the ranges.  
With an if/else or switch/case statements.  
It is not scalable, but if you need it for a low number of ranges it might work.

Thanks

---

<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:** [June 29, 2021, 1:53am UTC](https://discuss.elastic.co/t/find-ip-in-between-two-ranges/274104/6 "2021-06-29T01:53:35Z")

</div>

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