cidr

Converting CIDR address to subnet mask and network address

心不动则不痛 提交于 2019-11-27 00:42:20
Given a CIDR address, e.g. 192.168.10.0/24 How to determine mask length? ( 24 ) How to determine mask address? ( 255.255.255.0 ) How to determine network address? ( 192.168.10.0 ) Yuriy It is covered by apache utils. See this URL: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html String subnet = "192.168.0.3/31"; SubnetUtils utils = new SubnetUtils(subnet); utils.getInfo().isInRange(address) Note: For use w/ /32 CIDR subnets, for exemple, one needs to add the following declaration : utils.setInclusiveHostCount(true); This is how you would do it

Matching an IP to a CIDR mask in PHP 5?

怎甘沉沦 提交于 2019-11-26 21:40:48
I'm looking for quick/simple method for matching a given IP4 dotted quad IP to a CIDR notation mask. I have a bunch of IPs I need to see if they match a range of IPs. example: $ips = array('10.2.1.100', '10.2.1.101', '10.5.1.100', '1.2.3.4'); foreach ($ips as $IP) { if (cidr_match($IP, '10.2.0.0/16') == true) { print "you're in the 10.2 subnet\n"; } } What would cidr_match() look like? It doesn't really have to be simple, but fast would be good. Anything that uses only built-in/common functions is a bonus (as I'm likely to get one person to show me something in pear that does this, but I can't

List of IP Space used by Facebook [closed]

十年热恋 提交于 2019-11-26 18:55:37
问题 I am looking for an authoritative list of IP space Facebook uses. I need this to support a locked down developer environment that has very tight restrictions on outbound connectivity. Today I found api and graph.facebook.com started resolving to 69.171.224.0/19 which was not previously in my filters. I've updated it but I'd like to know what other IP space I'm missing allow rules for. Here's what I have currently. Any additional IP blocks you can list out would be great. Thanks everyone. 69

How can I check if an ip is in a network in Python?

非 Y 不嫁゛ 提交于 2019-11-26 14:08:44
Given an ip address (say 192.168.0.1), how do I check if it's in a network (say 192.168.0.0/24) in Python? Are there general tools in Python for ip address manipulation? Stuff like host lookups, ip adddress to int, network address with netmask to int and so on? Hopefully in the standard Python library for 2.5. This article shows you can do it with socket and struct modules without too much extra effort. I added a little to the article as follows: import socket,struct def makeMask(n): "return a mask of n bits as a long integer" return (2L<<n-1) - 1 def dottedQuadToNum(ip): "convert decimal

Converting CIDR address to subnet mask and network address

谁说我不能喝 提交于 2019-11-26 09:27:03
问题 Given a CIDR address, e.g. 192.168.10.0/24 How to determine mask length? ( 24 ) How to determine mask address? ( 255.255.255.0 ) How to determine network address? ( 192.168.10.0 ) 回答1: It is covered by apache utils. See this URL: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html String subnet = "192.168.0.3/31"; SubnetUtils utils = new SubnetUtils(subnet); utils.getInfo().isInRange(address) Note: For use w/ /32 CIDR subnets, for exemple, one