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.
Questions tagged [cidr]
397 questions
8
votes
3 answers
Convert CIDR notation into IP range
We are using the GeoLite2 database in order to implement an IP -> country lookup. For performance reasons, we want to import the CSV and convert it to our own format.
The CSV is represented like…

bytecode77
- 14,163
- 30
- 110
- 141
8
votes
3 answers
Calculate CIDR from a given netmask - Java
Is there a way to calculate a CIDR given a Sub net mask using any Java lib/function/trick?? I have been looking for a while and all I can find is from CIDR -> Netmask and I need it the other way arround Netmask -> CIDR ... Im not that handy on…

PzP01
- 93
- 1
- 5
8
votes
1 answer
As IPV6 needs 128 bits(16 bytes) then why in postgres CIDR datatype has storage as 24 byte(8.1) and 19byte(9.1)?
i am working with ipv4 and ipv6 to store in postgres db.
as ipv4 needs 32 bits(4byte) and ipv6 needs 128(16byte) bits.then why in postgres CIDR and INET datatype has the storage as 12 byte and 24 bytes respectively for IPV4 and IPV6(8.1).
with…

Asha Koshti
- 2,763
- 4
- 22
- 30
8
votes
3 answers
How to compare IP address range in C#?
If I have an IP address range (CIDR notation) and I need to know if some arbitrary IP address is within that range -- both presented as strings -- what is the easiest way to do this with C#?
Examples:
IPv4 Range: 192.168.168.100/24, IP to check:…

ahmd0
- 16,633
- 33
- 137
- 233
7
votes
4 answers
Determine the network and host ID portion of an IP address
I need to work out the algorithm regarding how you calculate the network and host portion of an IP address.
Is the host ID the public part? Is the network ID the private part for locating the computer within the local network?
If the subnet mask is…

fwc
- 331
- 2
- 5
- 11
7
votes
1 answer
How do I decide the CIDR blocks for public and private subnets and VPC?
I would like to create a VPC in AWS with a private subnet and a public subnet. I am using Terraform.
Here is what I have so far:
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16" # <---
enable_dns_support = true
enable_dns_hostnames =…

sdgfsdh
- 33,689
- 26
- 132
- 245
7
votes
1 answer
How to specify a CIDR block that covers only one address?
When configuring an AWS routing table, I want to enter the destination address A.B.C.D. In the routing table, I can select either A.B.C.D/28 or A.B.C.D/32.
Which of them means A.B.C.D only (only this one address)?
My answer:…

Glory to Russia
- 17,289
- 56
- 182
- 325
7
votes
2 answers
php cidr prefix to netmask
I'm looking to convert a cidr prefix (e.g. /28) to a netmask (e.g. 255.255.255.240) and have not located a function for this, does one exist in php? If not, how would I go about doing this?

phpnoobipv4
- 71
- 1
- 1
- 2
7
votes
4 answers
Bash - Convert netmask in CIDR notation?
Example:
I have this netmask: 255.255.255.0
Is there, in bash, a command or a simple script to convert my netmask in notation
/24?

Alex_DeLarge
- 325
- 1
- 2
- 8
7
votes
2 answers
List IP all addresses in a subnet
I need to get all of the IP addresses contained in within a subnet and I'm trying to do it using IPnetwork
For example the subnet 192.168.1.0/29 would have the following output:
// Output
// 192.168.1.0
// 192.168.1.1
…

Ray Womack
- 1,010
- 1
- 9
- 12
7
votes
4 answers
How can I generate all possible IPs from a list of ip ranges in Python?
Let's say I have a text file contains a bunch of ip ranges like this:
x.x.x.x-y.y.y.y
x.x.x.x-y.y.y.y
x.x.x.x-y.y.y.y
x.x.x.x-y.y.y.y
x.x.x.x-y.y.y.y
x.x.x.x is start value and y.y.y.y is end value of range.
How can I convert these ip ranges to all…

Someone
- 728
- 2
- 12
- 23
7
votes
6 answers
How can I convert IP range to Cidr in C#?
There has lots of example of convert CIDR to ip range. But I want to know how can I use start/end ip address to generate a/some cidr in C#?
for example:
I have start ip address(192.168.0.1) and end ip address(192.168.0.254). So use these two…

Chengzhao Li
- 81
- 1
- 3
7
votes
4 answers
IP Range to CIDR in Ruby/Rails?
I want to do two things: Convert IP Address inputs into CIDR
Here are some example inputs:
1.1.1.1
192.168.*.* #=> 192.168.0-255.0-255
192.168.1.2-20
1.1.1-10.1-100
Check if a given IP Address falls into any CIDR. This must be a very fast…

John
- 485
- 2
- 5
- 15
6
votes
1 answer
ipSecurity - how to add range of ip addresses
We have a requirement to whitelist the range of IP addresses from WAF) below:
199.83.128.0/21
198.143.32.0/19
149.126.72.0/21
103.28.248.0/22
45.64.64.0/22
185.11.124.0/22
192.230.64.0/18
More…

Nil Pun
- 17,035
- 39
- 172
- 294
6
votes
2 answers
Converting CIDR notation to IP range in java
How can I convert cidr to ip range in java ? I have used apache SubnetUtils but its ignoring first and last value of the range.
e.g
for CIDR 192.168.1.0/16 output should be 192.168.0.0 to 192.168.255.255.
but I am getting 192.168.0.1 to…

Rahman
- 3,755
- 3
- 26
- 43