Difference between revisions of "Networking: some CIDR calculations"

From Robs_Wiki
Jump to: navigation, search
Line 11: Line 11:
 
0 = 00000000 <br />
 
0 = 00000000 <br />
 
192.168.1.0 = 11000000.10101000.00000001.00000000 <br />
 
192.168.1.0 = 11000000.10101000.00000001.00000000 <br />
 +
 +
== Example 1 CIDR block 172.16.0.0/12 ==
 +
 +
1. What is the subnet mask? the first 12 bits are used (/12), which are all ones. the remaining bits are all zeros.<br />
 +
11111111.11110000.00000000.00000000 => 255.240.0.0 <br /><br />
 +
 +
2. What is the network identifier?<br />
 +
First translate the IP address in a binary number: (Use 128-64-32-16-8-4-2-1 to help calculate)<br />
 +
10101100.00010000.00000000.00000000<br />
 +
The network part is formed by the first 12 bits.<br />
 +
This corresponds to 10101100.0001<br /><br />
 +
 +
3 Number of available hosts?<br />
 +
2(32-12) – 3 = 1048573<br /><br />
 +
 +
3. What is the first and the last IP address available?<br />
 +
The first IP address is the network address plus all zero's for the host address:<br />
 +
10101100.00010000.0000.00000000 => 172.16.0.0<br />
 +
The last IP address is the network address plus all ones for the host addresss:<br />
 +
10101100.00011111.11111111.11111111 => 172.31.255.255<br />
 +
However, host IP addresses 172.16.0.0, 172.16.0.1 and 172.31.255.255 are reserved. (.0 for the network address, .1 for the default gateway and .255 for the broadcast address)<br />
 +
Usable IP range: 172.16.0.2 – 172.31.255.254<br />

Revision as of 20:50, 26 November 2020

How to convert a number to a binary number

In the networking IP4 calculations, an IP address is composed of 32 bits, divided into 4 octets: 00000000.00000000.00000000.00000000 The binary numbers available per octet are: 128 - 64 -32 -16-8- 4 -2-1

How to translate a number to a binary number? 192.168.1.0
128 - 64 -32 -16-8- 4 -2-1
192 = 128 + 64 = 11000000
168 = 128 + 32 + 8 = 10101000
1 = 00000001
0 = 00000000
192.168.1.0 = 11000000.10101000.00000001.00000000

Example 1 CIDR block 172.16.0.0/12

1. What is the subnet mask? the first 12 bits are used (/12), which are all ones. the remaining bits are all zeros.
11111111.11110000.00000000.00000000 => 255.240.0.0

2. What is the network identifier?
First translate the IP address in a binary number: (Use 128-64-32-16-8-4-2-1 to help calculate)
10101100.00010000.00000000.00000000
The network part is formed by the first 12 bits.
This corresponds to 10101100.0001

3 Number of available hosts?
2(32-12) – 3 = 1048573

3. What is the first and the last IP address available?
The first IP address is the network address plus all zero's for the host address:
10101100.00010000.0000.00000000 => 172.16.0.0
The last IP address is the network address plus all ones for the host addresss:
10101100.00011111.11111111.11111111 => 172.31.255.255
However, host IP addresses 172.16.0.0, 172.16.0.1 and 172.31.255.255 are reserved. (.0 for the network address, .1 for the default gateway and .255 for the broadcast address)
Usable IP range: 172.16.0.2 – 172.31.255.254