# ipaddr cidr\_lookup

**URL:** <https://forum.ansible.com/t/ipaddr-cidr-lookup/33191>\
**Category:** Ansible Project\
**Created:** [June 15, 2020, 11:27pm UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191 "2020-06-15T23:27:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanmerolle](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@ryanmerolle](https://forum.ansible.com/u/ryanmerolle)\
**Post date:** [June 15, 2020, 11:27pm UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191/1 "2020-06-15T23:27:38Z")

</div>

Anyone use this filter function? It seems like a lookup to see if an IP or subnet is a member of a larger prefix.

[https://github.com/ansible-collections/ansible.netcommon/blob/master/plugins/filter/ipaddr.py#L665](https://github.com/ansible-collections/ansible.netcommon/blob/master/plugins/filter/ipaddr.py#L665)

I am just not sure on the proper usage.

Thanks!

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [June 15, 2020, 11:54pm UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191/2 "2020-06-15T23:54:55Z")

</div>

Hi,

There are some great examples on the ipaddr filter’s documentation page: [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters\_ipaddr.html#playbooks-filters-ipaddr](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters_ipaddr.html#playbooks-filters-ipaddr)

Yes, one of the things you can do is check to see if an IP belongs to a subnet.

---

<div class="post-metadata">

**Author:** ![ryanmerolle](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@ryanmerolle](https://forum.ansible.com/u/ryanmerolle)\
**Post date:** [June 15, 2020, 11:58pm UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191/3 "2020-06-15T23:58:03Z")

</div>

Hello Scott,

I’m very familiar with the documented functions of the ipaddr filter. If you look at the link you just sent cidr\_lookup is not a documented function, but it is listed in the source code of the filter as I linked to in my original post.

Thanks!

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [June 16, 2020, 12:13am UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191/4 "2020-06-16T00:13:53Z")

</div>

I think what you’re asking for can be found by looking at the example for “By specifying a network range as a query, you can check if a given value is in that range:” in the docs.

An example playbook:

---

<div class="post-metadata">

**Author:** ![ryanmerolle](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@ryanmerolle](https://forum.ansible.com/u/ryanmerolle)\
**Post date:** [June 16, 2020, 2:05am UTC](https://forum.ansible.com/t/ipaddr-cidr-lookup/33191/5 "2020-06-16T02:05:04Z")

</div>

Scott,

I appreciate your patience here. Even when I said I am very familiar with the document, you pressed on and pointed me to the item that was right in front of my face! That worked perfectly

Thanks!
