# Does logstash-filter-cidr support mutiple address match like if condition

**URL:** <https://discuss.elastic.co/t/does-logstash-filter-cidr-support-mutiple-address-match-like-if-condition/206882>\
**Category:** Logstash\
**Created:** [November 7, 2019, 4:20am UTC](https://discuss.elastic.co/t/does-logstash-filter-cidr-support-mutiple-address-match-like-if-condition/206882 "2019-11-07T04:20:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tacyeh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tacyeh/32/57297_2.png) [@tacyeh](https://discuss.elastic.co/u/tacyeh)\
**Post date:** [November 7, 2019, 4:20am UTC](https://discuss.elastic.co/t/does-logstash-filter-cidr-support-mutiple-address-match-like-if-condition/206882/1 "2019-11-07T04:20:57Z")

</div>

I want add a field `{"key" => "value1"}` when address match "192.168.1.1/24", add a field `{"key" => "value2"}` when address match "192.168.2.1/24"..., but accord [the reference](https://www.elastic.co/guide/en/logstash/current/plugins-filters-cidr.html), I wrote configs like this:

```auto
filter {
        cidr {
        add_field => {"key" => "value1"}
        address => ["%{host}", "%{ip}"]
        network => ["192.168.1.1/24"]
    }
}

filter {
        cidr {
        add_field => {"key" => "value2"}
        address => ["%{host}", "%{ip}"]
        network => ["192.168.2.1/24"]
    }
}

...

filter {
        cidr {
        add_field => {"key" => "valueN"}
        address => ["%{host}", "%{ip}"]
        network => ["192.168.N.1/24"]
    }
}

```

my understanding: these all filters will process the event.

my aims is that if address matches rule a, it will not matches rule b. like `if ... else if ... else ...`

forgive me poor english.

---

<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:** [December 5, 2019, 4:21am UTC](https://discuss.elastic.co/t/does-logstash-filter-cidr-support-mutiple-address-match-like-if-condition/206882/2 "2019-12-05T04:21:04Z")

</div>

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