# CIDR filter detect which ip matched

**URL:** <https://discuss.elastic.co/t/cidr-filter-detect-which-ip-matched/193051>\
**Category:** Logstash\
**Created:** [July 31, 2019, 7:26am UTC](https://discuss.elastic.co/t/cidr-filter-detect-which-ip-matched/193051 "2019-07-31T07:26:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![freki](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/freki/32/41348_2.png) [@freki](https://discuss.elastic.co/u/freki)\
**Post date:** [July 31, 2019, 7:26am UTC](https://discuss.elastic.co/t/cidr-filter-detect-which-ip-matched/193051/1 "2019-07-31T07:26:36Z")

</div>

hey guys 🙂

i wonder if it is possible to set a tag within the cidr filter depending on what ip (src or dst) matched the network.  
this is my code so far.

```
cidr {
                address => ["%{src_ip}", "%{dst_ip}"]
                network => ['10.1.1.0/24']
                add_tag => ['match_src']
            }

```

So basically, i want the tag "match\_src" if the source ip matched the network and "matched\_dst" if the destination ip matched the network.  
Is this possible? I know i could just use the cidr code 2 times, but i am worried about performance, since a large set of data will run through the filter.

many thanks in advance!!

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [July 31, 2019, 8:43am UTC](https://discuss.elastic.co/t/cidr-filter-detect-which-ip-matched/193051/2 "2019-07-31T08:43:44Z")

</div>

I looked at the code, unfortunately, the CIDR filter does not have this functionality. Two filters is your only option.

---

<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 28, 2019, 8:51am UTC](https://discuss.elastic.co/t/cidr-filter-detect-which-ip-matched/193051/3 "2019-08-28T08:51:05Z")

</div>

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