简体   繁体   中英

Cidr format of ip

How would I go about writing Ipaddress range :- 80.83.228.0 - 80.83.231.255 in format like 80.83.224.0/127?

I have tried the below format.

I have Ipaddress range :- 80.83.228.0 - 80.83.231.255

and i want to use Like this format (for example 80.83.224.0/127) in order to parse in the following programmatic expression:

IPNetwork.Parse("80.83.224.0/127").

I have tried out this.

IPNetwork.Parse("80.83.228.0/231.255")

Can anybody please help? I know it is a very basic question but I am new to this.

The notation you are looking to find out about is called CIDR notation.

(Classless Inter Domain Routing)

What you need is IPNetwork.Parse("80.83.228.0/22")

Find out more here.

It can all get quite confusing and this is one of the concepts that rookie network engineers find most confusing. Ill try and provide a simplified explanation as follows:

If you break down the IP addresses provided into binary it all becomes a lot easier.

The network address is the ip address where all of the host bits (the 0's in the subnet mask) are 0,and the last address, the broadcast address, is where all the host bits are 1.

For example:

ip 80.83.228.0 is as seen below

01010000.01010011.11100100.00000000 (lower ip address)

and

ip 80.83.228.0 is as seen below

01010000.01010011.11100111.00000000 (upper ip address)

We can see that these addresses are the same up until the 22nd bit therefore you need to set your bit mask at 22.

ie /22

The first part of the address is the network address and this is always the lowest address in the network so we set all bits to the right of the bit mask delimiter to zero giving us the following:

01010000.01010011.111001/00.00000000

Note I have added the slash to show you the split here.

converting back to decimal and putting the two parts together gives us:

80.83.228.0/22

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM