Questions tagged [cidr]

Classless Inter-Domain Routing, a method for allocating TCP/IP network addresses and routing data packets. Divides IP address into network id (high bits) and host id (low bits) as determined by netmask. In 1993, replaced the older classful network routing.

397 questions
17
votes
4 answers

How to convert CIDR to network and IP address range in C#?

I have been looking around quite a bit to find some C# code to convert a network in CIDR notation (72.20.10.0/24) to an IP address range, without much luck. There are some threads about CIDR on stackoverlow, but none seems to have any C# code and…
Kurt
  • 695
  • 3
  • 8
  • 17
12
votes
2 answers

Splitting an IPv6 cidr into /64 blocks, in php

I'm looking to create a script that will take an ipv6 range or cidr as input, and spit out a list of /64 blocks (or the first IP in each /64 block). I have a function that does something similar for IPv4 IPs, but I lack the understanding to…
Moist_Gerbil
  • 195
  • 7
11
votes
7 answers

Matching IPv6 address to a CIDR subnet

Is there a good way to match an IPv6 address to an IPv6 subnet using CIDR notation? What I am looking for is the IPv6 equivalent to this: Matching an IP to a CIDR mask in PHP 5? The example given above can't be used since an IPv6 address is 128 bits…
MW.
  • 12,550
  • 9
  • 36
  • 65
11
votes
1 answer

Getting 'Must be valid Ipv4 CIDR' error after passing subnet's CIDR block

I have created a VPC(public and private subnets) on AWS with IPV4 CIDR block as 10.0.0.0/26 (i.e. it can have 2^6 = 64 IP addresses along with one subnet address and one broadcast address). I want to create following two subnets but I am getting…
bot
  • 1,293
  • 3
  • 17
  • 34
11
votes
4 answers

convert cidr to subnet mask in python

I have a python dictionary that I've created, this dictionary contains a list of subnets in the following format: x.x.x.x/24 y.y.y,y/25 z.z.z.z/26 a.a.a.a/27 etc... I would like to take the items in this dictionary, parse it, then spit out the…
just1han85
  • 313
  • 1
  • 4
  • 14
11
votes
4 answers

Using SQL to determine cidr value of a subnet mask

I'd like to find a way to do a SQL query that will calculate the cidr (bit representation) of a subnet mask stored in the database. So for example, I've got either 255.255.255.0 or its decimal value (4294967040) stored in the database. I'd like to…
Matt P
  • 5,447
  • 4
  • 23
  • 20
11
votes
2 answers

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)

We are adapting our applications CloudFormation template to make use of VPC. Within this template we need to programmatically generate the CIDR blocks used for our VPC subnets, in order to ensure they do not conflict between CloudFormation…
user2610892
10
votes
3 answers

How to detect if two Golang net.IPNet objects intersect?

How to detect if there is intersection between two Golang net.IPNet objects? That is, how to check both if the first network is subnet of the second one OR if the second network is subnet of the first one. Does Go provide any utility function ready…
Everton
  • 12,589
  • 9
  • 47
  • 59
10
votes
7 answers

How to convert IP address range to CIDR in Java?

I am trying to convert the IP address range into the CIDR notation in Java. Can someone provide an example of how this can be achieved? I used the SubnetUtils for converting the CIDR to the IP address range, but I can't figure out the other way…
Dhaval Kotecha
  • 133
  • 1
  • 1
  • 9
9
votes
4 answers

Testing if a network in cidr notation overlaps another network

I'm searching for a php algorithm that efficiently test if one cidr notated network overlaps another. Basically I have the following situation: Array of cidr adresses: $cidrNetworks = array( '192.168.10.0/24', '10.10.0.30/20', etc. ); I…
Damien Overeem
  • 4,487
  • 4
  • 36
  • 55
9
votes
5 answers

Calculate an IPv6 range from a CIDR prefix?

I am able to do this with IPv4 using code snippets from various online sources. I was wondering if there was a way to do it with IPv6. Basically I just need a form that I can enter an IPv6 address and prefix (ex: f080:42d2:581a::0/68) and it…
Damainman
  • 515
  • 9
  • 21
8
votes
7 answers

List of IP addresses in Python to a list of CIDR

How do I convert a list of IP addresses to a list of CIDRs? Google's ipaddr-py library has a method called summarize_address_range(first, last) that converts two IP addresses (start & finish) to a CIDR list. However, it cannot handle a list of IP…
paragbaxi
  • 3,965
  • 8
  • 44
  • 58
8
votes
1 answer

How to convert CIDR to IP ranges using python3?

How to convert list like: 94.192.0.0/14 94.0.0.0/12 93.96.0.0/16 To: 94.192.0.0-94.195.255.255 94.0.0.0-94.15.255.255 93.96.0.0-93.96.255.255 Using python3?
tellst1
  • 83
  • 1
  • 5
8
votes
9 answers

Python regex to match IP-address with /CIDR

m = re.findall("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}",s) How do I modify it so it will match not only IPv4, but also something with CIDR like 10.10.10.0/24?
asdasdasd
  • 81
  • 1
  • 1
  • 2
8
votes
1 answer

Get the opposite of a CIDR Range

I'd like to make a list of CIDR ranges that represent the addresses outside of the CIDR range I specify. As a simplified example: If I have the IP ranges from 8.8.8.8 to 8.8.8.10, I would be able to express this with CIDR ranges 8.8.8.8/31 and…
cylondude
  • 1,816
  • 1
  • 22
  • 55
1
2
3
26 27