djangosnippets.org: Latest snippets tagged with 'ipaddr'https://djangosnippets.org/tags/ipaddr/2009-07-10T16:54:42.674004-05:00Test IP against IP address+Subnet whitelist
2009-07-10T16:54:42.674004-05:00mtigashttps://djangosnippets.org/snippets/1624/<p>Simple function that tests whether a given IP address is in a list of IP addresses or subnets.
</p>
<p>Requires <code>ipaddr</code>. Comes with Python 2.7 or 3.1, <a href="http://code.google.com/p/ipaddr-py/">downloadable here</a> for earlier versions.
</p>
<p>More info on <code>ipaddr</code> <a href="http://docs.python.org/dev/py3k/library/ipaddr.html">in Python 3.1 docs</a>.
</p>
Freely redistributable