Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • >>> netaddr.all_matching_cidrs("192.168.0.1", ["192.168.0.0/24","212.11.64.0/19"] ) [IPNetwork('192.168.0.0/24')] Commented Sep 6, 2011 at 17:25
  • 28
    Or in the new version: from netaddr import IPNetwork, IPAddress IPAddress("192.168.0.1") in IPNetwork("192.168.0.0/24") Commented Feb 13, 2013 at 12:37
  • 2
    Note that this approach, although nice API, requires installation of third-party module. Whereas the other answer, which discusses builtin ipaddress module, does not. Commented Nov 23, 2020 at 22:05