# 如何计算前缀，网络，子网和主机号？

97

IP：128.42.5.4

Answers:

164

## 计算网络掩码长度（也称为前缀）：

``````255.255.248.0   in binary: 11111111 11111111 11111000 00000000
-----------------------------------
I counted twenty-one 1s             -------> /21
``````

## 计算网络地址：

``````128.42.5.4      in binary: 10000000 00101010 00000101 00000100
255.255.248.0   in binary: 11111111 11111111 11111000 00000000
----------------------------------- [Logical AND]
10000000 00101010 00000000 00000000 ------> 128.42.0.0
``````

## 计算广播地址：

``````128.42.5.4      in binary: 10000000 00101010 00000101 00000100
``````

``````255.255.248.0   in binary: 11111111 11111111 11111000 00000000
``````

``````Host bit mask            : 00000000 00000000 00000hhh hhhhhhhh
``````

``````128.42.5.4      in binary: 10000000 00101010 00000101 00000100
Host bit mask            : 00000000 00000000 00000hhh hhhhhhhh
----------------------------------- [Force host bits]
10000000 00101010 00000111 11111111 ----> 128.42.7.255
``````

## 计算主机号：

``````128.42.5.4      in binary: 10000000 00101010 00000101 00000100
Host bit mask            : 00000000 00000000 00000111 11111111
----------------------------------- [Logical AND]
00000000 00000000 00000101 00000100 -----> 0.0.5.4
``````

## 查找包含两个IP地址的最大网络掩码（最小主机掩码）：

• 128.42.5.17
• 128.42.5.67

``````128.42.5.17     in binary: 10000000 00101010 00000101 00010001
128.42.5.67     in binary: 10000000 00101010 00000101 01000011
^                           ^     ^
|                           |     |
+--------- Network ---------+Host-+
(All bits are the same)    Bits
``````

15

``````128 64 32 16  8  4 2 1
SN  SN SN SN SN SN H H
1   0  0  1  1  1 1 1
``````

• 网络地址： 195.70.16.156
• 第一个可用地址： 195.70.16.157
• 最后可用地址： 195.70.16.158
• 广播地址： 195.70.16.159

• 第一个可用地址 =网络地址+ 1
• 广播地址 =下一个网络地址– 1
• 最后可用地址 =广播地址– 1

4

Mike Pennington

11

# 2之1

## IPv4数学

``````---------------------------------------------------------
| Bit # |   7 |   6 |   5 |   4 |   3 |   2 |   1 |   0 |
---------------------------------------------------------
| Value | 128 |  64 |  32 |  16 |   8 |   4 |   2 |   1 |
---------------------------------------------------------
``````

``````For our example IPv4 dotted-decimal address of 198.51.100.223:
1st octet: 198 = 128 + 64 +  0 +  0 + 0 + 4 + 2 + 0 = 11000110
2nd octet:  51 =   0 +  0 + 32 + 16 + 0 + 0 + 2 + 1 = 00110011
3rd octet: 100 =   0 + 64 + 32 +  0 + 0 + 4 + 0 + 0 = 01100100
4th octet: 223 = 128 + 64 +  0 + 16 + 8 + 4 + 2 + 1 = 11011111

For our example IPv4 binary address of 11000110001100110110010011011111:
1st octet: 11000110 = 128 + 64 +  0 +  0 + 0 + 4 + 2 + 0 = 198
2nd octet: 00110011 =   0 +  0 + 32 + 16 + 0 + 0 + 2 + 1 =  51
3rd octet: 01100100 =   0 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 100
4th octet: 11011111 = 128 + 64 +  0 + 16 + 8 + 4 + 2 + 1 = 223
``````

``````-----------------------------------------
| False AND False = False | 0 AND 0 = 0 |
-----------------------------------------
| False AND True  = False | 0 AND 1 = 0 |
-----------------------------------------
| True  AND False = False | 1 AND 0 = 0 |
-----------------------------------------
| True  AND True  = True  | 1 AND 1 = 1 |
-----------------------------------------

-----------------------------------------
| False OR False = False  | 0 OR 0 = 0  |
-----------------------------------------
| False OR True  = True   | 0 OR 1 = 1  |
-----------------------------------------
| True  OR False = True   | 1 OR 0 = 1  |
-----------------------------------------
| True  OR True  = True   | 1 OR 1 = 1  |
-----------------------------------------
``````

* 如果您执行IPv4数学多年，您可能会想到可以执行二进制/十进制转换，然后您似乎可以使用十进制进行IPv4数学。即使我能做到这一点，在将更改提交到生产网络之前，我始终会使用IP计算器进行仔细检查，或者转换为二进制，执行数学运算并转换回十进制。

## IPv4地址

``````Binary address: 11000110001100110110010011011111
---------------------------------------------
Binary octets:  | 11000110 | 00110011 | 01100100 | 11011111 |
Decimal octets: |      198 |       51 |      100 |      223 |
---------------------------------------------
Dotted-decimal: 198.51.100.223
``````

``````Dotted-decimal: 198.51.100.223
---------------------------------------------
Decimal octets: |      198 |       51 |      100 |      223 |
Binary octets:  | 11000110 | 00110011 | 01100100 | 11011111 |
---------------------------------------------
Binary address: 11000110001100110110010011011111
``````

* 点分十进制IPv4地址中的前导零可能被某些应用程序和编程语言解释为八进制（基数8）而不是十进制（基数10），从而导致错误，对于点分十进制IPv4表示，应避免前导零，但是对于二进制IPv4地址八位字节，前导零是必需的，因为它们表示完整地址中的位位置，而省略位位置将缩短地址并更改二进制值。

## IPv4网络掩码

IPv4网络掩码用于将IPv4地址分为两部分：网络部分和主机部分。除法可以是任意位数，因此它可能属于一个八位位组，而不是八位位组边界，因为许多人错误地认为它总是如此。IPv4网络掩码的大小与IPv4地址的大小（32位）相同，并且以点分十进制表示法表示，其方式与点分十进制表示法IPv4地址的表示方式相同（四个八位八位字节，用逗号分隔）期）。例如，`255.255.248.0`

IPv4网络掩码由多个连续的`1`位（代表地址的网络部分）和随后的许多`0`位（代表地址的主机部分）组成。总数`1`的比特和总数`0`比特加起来`32`，比特的IPv4地址或网络掩码数。对于我们的示例网络掩码：

``````Dotted-decimal: 255.255.248.0
------------------------------------------------
Decimal octets: |      255 |      255 |         248 |        0 |
Binary octets:  | 11111111 | 11111111 | 11111 | 000 | 00000000 |
------------------------------------------------
| 21 Network bits             | 11 Host bits   |
------------------------------------------------
``````

IPv4网络掩码通常由掩码中的连续`1`位数表示。这被不同地称为网络掩码长度或前缀长度，并且用网络掩码中`/`的连续`1`位数表示。对于我们的示例，计算连续`1`位数get `21`，可以表示为`/21`

``````Mask length:    /21
------------------------------------------------
| 21 Network bits             | 11 Host bits   |
------------------------------------------------
Binary octets:  | 11111111 | 11111111 | 11111 | 000 | 00000000 |
Decimal octets: |      255 |      255 |         248 |        0 |
------------------------------------------------
Dotted-decimal: 255.255.248.0
``````

## IPv4网络地址

IPv4网络地址是所有主机位都设置为的IPv4地址`0`。可以通过按`AND`IPv4地址和IPv4网络掩码的二进制表示形式的各个位按位计算IPv4网络地址。将两个地址中的位对齐，并`AND`在每对各自的位上按位执行，然后将结果的各个八位字节转换回十进制。

``````Decimal address:        198.51.100.223/21
Binary address octets:  11000110 00110011 01100100 11011111
Binary mask octets:     11111111 11111111 11111000 00000000 AND
-----------------------------------
Binary network octets:  11000110 00110011 01100000 00000000
Decimal network octets:      198       51       96        0
Dotted-decimal network: 198.51.96.0
``````

``````Decimal address:        198.51.102.57/21
Binary address octets:  11000110 00110011 01100110 00111001
Binary mask octets:     11111111 11111111 11111000 00000000 AND
-----------------------------------
Binary network octets:  11000110 00110011 01100000 00000000
Decimal network octets:      198       51       96        0
Dotted-decimal network: 198.51.96.0
``````

``````Decimal address:        74.125.69.100/21
Binary address octets:  01001010 01111101 01000101 01100100
Binary mask octets:     11111111 11111111 11111000 00000000 AND
-----------------------------------
Binary network octets:  01001010 01111101 01000000 00000000
Decimal network octets:       74      125       64        0
Dotted-decimal network: 74.125.64.0
``````

* 这是源主机用来确定它是否是与源主机位于同一网络上的目标主机的方法。

## IPv4主机掩码

``````Dotted-decimal network mask: 255.255.248.0
Decimal network mask octets:      255      255      248        0
Binary network mask octets:  11111111 11111111 11111000 00000000 invert
-----------------------------------
Binary host mask octets:     00000000 00000000 00000111 11111111
Decimal host mask octets:           0        0        7      255
Dotted-decimal host mask:    0.0.7.255
``````

``````Binary all-ones mask octets: 11111111 11111111 11111111 11111111
Binary network mask octets:  11111111 11111111 11111000 00000000 -
-----------------------------------
Binary host mask octets:     00000000 00000000 00000111 11111111
Decimal host mask octets:           0        0        7      255
Dotted-decimal host mask:    0.0.7.255
``````

``````Decimal all-ones mask octets: 255 255 255 255
Decimal network mask octets:  255 255 248   0 -
---------------
Decimal host mask octets:       0   0   7 255
Dotted-decimal host mask:     0.0.7.255
``````

## IPv4网络广播地址

IPv4网络广播地址是所有主机位都设置为的IPv4网络地址`1`。有几种方法可以计算IPv4网络广播地址。

``````Decimal address octets:        198       51      100      223
Binary address octets:    11000110 00110011 01100100 11011111
Binary host mask octets:  00000000 00000000 00000111 11111111 OR
-----------------------------------
Binary broadcast octets:  11000110 00110011 01100111 11111111
Decimal broadcast octets:      198       51      103      255
Dotted-decimal broadcast: 198.51.103.255
``````

``````Binary network octets:    11000110 00110011 01100000 00000000
Binary host mask octets:  00000000 00000000 00000111 11111111 +
-----------------------------------
Binary broadcast octets:  11000110 00110011 01100111 11111111
Decimal broadcast octets:      198       51      103      255
Dotted-decimal broadcast: 198.51.103.255
``````

``````Decimal network octets:   198  51  96   0
Decimal host mask octets:   0   0   7 255 +
---------------
Decimal broadcast octets: 198  51 103 255
Dotted-decimal broadcast: 198.51.103.255
``````

## 第一个可用的IPv4网络主机地址

`/31`（网络掩码`255.255.255.254`）和`/32`（网络掩码`255.255.255.255`）网络外，第一个可用的IPv4网络主机地址是IPv4网络地址加`1`（IPv4网络地址不可用于网络主机地址）。对于我们的示例网络`198.51.96.0/21`，第一个可用的网络主机地址是`198.51.96.1``198.51.96.0 + 1 = 198.51.96.1`）。只需将二进制IPv4网络地址的低位设置为`1`

``````Decimal network octets:      198       51       96        0
Binary network octets:  11000110 00110011 01100000 00000000
-----------------------------------
Binary address octets:  11000110 00110011 01100000 00000001
Decimal address octets:      198       51       96        1
Dotted-decimal address: 198.51.96.1
``````

## 最后可用的IPv4网络主机地址

`/31`（网络掩码`255.255.255.254`）和`/32`（网络掩码`255.255.255.255`）网络外，最后可用的IPv4网络主机地址是IPv4网络广播地址减`1`（IPv4网络广播地址不可用于网络主机地址）。对于我们的示例网络`198.61.96.0/21`，最后一个可用的网络主机地址是`198.51.103.254``198.51.103.255 - 1 = 198.51.103.254`）。只需将二进制IPv4网络广播地址的低位设置为`0`

``````Decimal broadcast octets:      198       51      103      255
Binary broadcast octets:  11000110 00110011 01100111 11111111
-----------------------------------
Binary address octets:    11000110 00110011 01100111 11111110
Decimal address octets:        198       51      103      254
Dotted-decimal address:   198.51.103.254
``````

## 将IPv4网络寻址放在一起

``````Host address:                       198.51.100.223
Network mask:                       255.255.248.0
Network mask length:                21
Host mask:                          0.0.7.255
Host mask length:                   11
*Network address:                   198.51.96.0
*First usable network host address: 198.51.100.1
*Last usable network host address:  198.51.103.254
*Network Broadcast address:         198.51.103.255
Total network host addresses:       2048
Usable network host addresses:      2046
``````

* 网络教育课程考试和认证考试将要求您能够在给定主机地址和掩码（或掩码长度）的情况下针对IPv4网络快速计算这些值。您可以使用以下提示快速查看答案：

• 网络地址（提示：偶数）
• 第一个可用的主机地址（提示：网络地址加1，一个奇数）
• 最后可用的主机地址（提示：广播地址减1，偶数）
• 广播地址（提示：网络地址加主机掩码，一个奇数）

9

# 2之2

## IPv4 `/32`（网络掩码`255.255.255.255`）网络

`/32`（网络掩码`255.255.255.255`）网络既是没有主机地址网络，和一个主机地址，本身。网络中只有一个地址，即网络地址。由于网络上没有其他主机，因此必须将流量路由到网络地址和从网络地址路由。

## 子网划分IPv4网络

``````Log2(14 subnets) = 3.807354922, rounded up = 4 borrowed bits
``````

``````           ----------------------------------------------
Original:  | 21 network bits       | 11 host bits       |
----------------------------------------------
Network:   | 110001100011001101100 | 0000 |  0000000    | = 198.51.96.0/21
Subnet 1:  | 110001100011001101100 | 0000 |  0000000    | = 198.51.96.0/25
Subnet 2:  | 110001100011001101100 | 0001 |  0000000    | = 198.51.96.128/25
Subnet 3:  | 110001100011001101100 | 0010 |  0000000    | = 198.51.97.0/25
Subnet 4:  | 110001100011001101100 | 0011 |  0000000    | = 198.51.97.128/25
Subnet 5:  | 110001100011001101100 | 0100 |  0000000    | = 198.51.97.128/25
Subnet 6:  | 110001100011001101100 | 0101 |  0000000    | = 198.51.98.128/25
Subnet 7:  | 110001100011001101100 | 0110 |  0000000    | = 198.51.99.0/25
Subnet 8:  | 110001100011001101100 | 0111 |  0000000    | = 198.51.99.128/25
Subnet 9:  | 110001100011001101100 | 1000 |  0000000    | = 198.51.100.0/25
Subnet 10: | 110001100011001101100 | 1001 |  0000000    | = 198.51.100.128/25
Subnet 11: | 110001100011001101100 | 1010 |  0000000    | = 198.51.101.0/25
Subnet 12: | 110001100011001101100 | 1011 |  0000000    | = 198.51.101.128/25
Subnet 13: | 110001100011001101100 | 1100 |  0000000    | = 198.51.102.0/25
Subnet 14: | 110001100011001101100 | 1101 |  0000000    | = 198.51.102.128/25
----------------------------------------------
Subnetted: | 25 network bits              | 7 host bits |
----------------------------------------------

----------------------------------------------
Unused:    | 110001100011001101100 | 111  | 00000000    | = 198.51.103.0/24
----------------------------------------------
``````

*一直存在一个神话，即对于子网和主机地址，不能使用全零和全一子网，但是很多年前标准已明确消除了这一神话。不幸的是，这个神话扩展到某些网络教育班级，而那些（不正确的）班级的正确答案是使用第二到第十五子网。

`/26`子网开始：

``````Original: | 110001100011001101100 | 00000000000    | /21
Subnet 1: | 110001100011001101100 | 00000 | 000000 | /26
``````

``````Subnet 2: | 110001100011001101100 | 00001 | 000000 | /26
``````

``````Subnet 2: | 110001100011001101100 | 000010 | 00000 | /27
``````

`/27`子网开始：

``````Original: | 110001100011001101100 | 00000000000    | /21
Subnet 1: | 110001100011001101100 | 000000 | 00000 | /27
``````

``````Subnet 2: | 110001100011001101100 | 000001 | 00000 | /27
``````

``````Original: | 110001100011001101100 | 00000000000     | /21
Subnet 1: | 110001100011001101100 | 000000 |  00000 | /27
Unused:   | 110001100011001101100 | 000001 |  00000 | /27
Subnet 2: | 110001100011001101100 | 00001  | 000000 | /26
``````

## 基于主机数的子网大小

``````Given the 198.51.96.0/21 network, subnet it for the following departments:
Department 1:  500 hosts
Department 2:  100 hosts
Department 3:  200 hosts
Department 4: 1000 hosts
``````

``````Department 4: 1000 hosts
Department 1:  500 hosts
Department 3:  200 hosts
Department 2:  100 hosts
``````

``````Department 4: 1024 total host addresses = 2^10 = 10 host bits
Department 1:  512 total host addresses = 2^9  =  9 host bits
Department 3:  256 total host addresses = 2^8  =  8 host bits
Department 2:  128 total host addresses = 2^7  =  7 host bits
``````

``````Department 4: Log2(1000 hosts) = 9.96578428466209, rounded up = 10 host bits
Department 1: Log2( 500 hosts) = 8.96578428466209, rounded up =  9 host bits
Department 3: Log2( 200 hosts) = 7.64385618977472, rounded up =  8 host bits
Department 2: Log2( 100 hosts) = 6.64385618977473, rounded up =  7 host bits
``````

``````Original:     | 110001100011001101100 |    00000000000 | = 198.51.96.0/21
Department 4: | 110001100011001101100 | 0 | 0000000000 | = 198.51.96.0/22
Department 1: | 110001100011001101100 | 10 | 000000000 | = 198.51.100.0/23
Department 3: | 110001100011001101100 | 110 | 00000000 | = 198.51.102.0/24
Department 2: | 110001100011001101100 | 1110 | 0000000 | = 198.51.103.0/25
Unused:       | 110001100011001101100 | 1111 | 0000000 | = 198.51.103.128/25
``````

## 查找特定子网

``````Original:  | 110001100011001101100 |    00000000000 | = 198.51.96.0/21
Subnet 23: | 110001100011001101100 | 10110 | 000000 | = 198.51.101.128/26
``````

``````Network address:                   198.51.101.128
Network mask length:               26
Network mask:                      255.255.255.192
Host mask length:                  6
Host mask:                         0.0.0.63
First usable network host address: 198.51.101.1
Last usable network host address:  198.51.101.62
Broadcast address:                 198.51.101.63
Total network host addresses:      64
Usable network host addresses:     62
``````

*一直存在一个神话，即对于子网和主机地址，不能使用全零和全一子网，但是很多年前标准已明确消除了这一神话。不幸的是，这个神话扩展到某些网络教育班级，对于那些（错误的）班级来说，正确的答案是在我们等大小子网的示例中使用第24个（`23`十进制，`10111`二进制）子网，而不是实际的第23个（`22`十进制，`10110`二进制）子网。

## 查找特定的网络主机

``````Binary network: | 110001100011001101100 | 00000000000 |
Binary 923:     | 000000000000000000000 | 01110011011 | +
-----------------------------------
Host address:   | 110001100011001101100 | 01110011011 | = 198.51.99.155
``````

## 两台主机的最大公共网络*

``````198.51.100.223 = 11000110001100110110010011011111
198.51.101.76  = 11000110001100110110010101001100
``````

``````198.51.100.223 = | 11000110001100110110010 | 011011111 |
198.51.101.76  = | 11000110001100110110010 | 101001100 |
``````

`23`在这种情况下，请计算匹配位数，以获取掩码长度。然后，您可以选择其中一个地址，并`AND`使用网络掩码按位执行操作以获取公共网络。在两个地址上都执行此操作将导致一个相同的网络，如果不相同，则可能会计数错误，或者错过了不匹配的位位置。

``````198.51.100.223  = 11000110001100110110010011011111
/23 mask length = 11111111111111111111111000000000 AND
--------------------------------
Binary network:   11000110001100110110010000000000 = 198.51.100.0/23

198.51.101.76   = 11000110001100110110010111011111
/23 mask length = 11111111111111111111111000000000 AND
--------------------------------
Binary network:   11000110001100110110010000000000 = 198.51.100.0/23
``````

* 您可能会看到这称为最小的公共网络（或某些变体，例如最小网络或掩码）。最小的网络实际上是`0.0.0.0/0``0`网络位），它是所有IPv4地址的公用网络，因此它是任何IPv4地址之间的最小公用网络。之所以会出现这种混乱，是因为许多人都在查看地址的主机部分，并将其大小视为网络大小，而不是地址的网络部分大小。

## 公开与私有寻址

IPv4本身不具有公共寻址和专用寻址的概念，也没有区别。IPv4专用寻址是任意选择的，根据协议，ISP不会使用专用地址空间中的地址在公共Internet上转发数据包，但是网络设备和主机不知道地址是公用还是专用。

1. `10.0.0.0/8`
2. `172.16.0.0/12`
3. `192.168.0.0/16`

## 分类网络寻址

IPv4地址类别均基于地址的前几位：

``````Class   Address Starts With      Address Range                 Default Size*
A     First one bit    = 0       0.0.0.0 to 127.255.255.255        /8
B     First two bits   = 10    128.0.0.0 to 191.255.255.255       /16
C     First three bits = 110   192.0.0.0 to 223.255.255.255       /24
D     First four bits  = 1110  224.0.0.0 to 239.255.255.255       N/A
E     First four bits  = 1111  240.0.0.0 to 255.255.255.255       N/A
``````
• A类网络的默认网络掩码为`255.0.0.0``/8`），默认的主机掩码为`0.255.255.255`，为您提供`16,777,216`每个网络的总主机地址。
• B类网络的默认网络掩码为`255.255.0.0``/16`），默认的主机掩码为`0.0.255.255`，为您提供`65,536`每个网络的总主机地址。
• C类网络的默认网络掩码为`255.255.255.0``/24`），默认的主机掩码为`0.0.0.255`，为您提供`256`每个网络的总主机地址。
• D类地址用于多播，其中每个地址分别用于表示订阅多播地址的一组主机。这意味着D类地址通常不具有网络掩码的概念。
• E类地址是保留的，不能用于任何用途。对此有一个例外，那就是的受限广播地址`255.255.255.255`，它是网络上每个主机都将视为自己的地址。这意味着发送到的任何内容都`255.255.255.255`将被网络上的每个主机接收和处理。

``````Binary: 11000110 00110011 01100100 11011111
``````

* 不要误以为网络掩码决定了网络类别，这是相反的做法。例如，许多人认为任何`/24`网络都属于C类网络，但事实并非如此。例如，在给定`10.11.12.0/24`网络的情况下，即使地址的第一位是`0`，它也会由于网络掩码错误地将其称为C类网络，即使它的网络掩码比默认值更长，也使其成为A类网络。 A类网络掩码，表示它是A类网络的子网，而不是C类网络的子网。

6

（为了将所有网络掩码答案都保留在一个位置，在其他出色答案之后，我添加了关于视觉方法的一个。）

• 您的起始块总共有多少个地址可用？
• 假设将/ 22划分为1024个地址
• 得到一张具有那么多平方厘米（和正方形或2x1比率）的纸
• 因此，我得到一块32厘米乘32厘米（1024平方厘米）的零件
• 反复
1. 选择一块（如果有多个）
2. 将其切成两半（在限制范围内：仅将矩形切成两半，在1厘米以下不要切任何东西）
• 通常您可以做出不同的削减，因此必须做出选择
• 要获得n个网络，您需要进行n-1个切割
• 有时，您最终会得到多余的碎片（取决于您如何分配“废物”）

• 每个所需的大小取整为足够大的最小块
• 确保您遵循所有全局规则（通常“最大化可用地址”，有时“允许增长两倍”或“简化路由”）
• 将子网分配给地址，从最大的地址开始，到最小的地址（这是他们通常忘记告诉您的部分
• 遵循任何特定的规则（测试问题通常具有额外的规则，有时诸如“没有网络地址可以包含7”之类的缩写）
• 检查是否有隐含地址的空间（广播，路由器）
• 如果网络较小（/ 30，/ 31或/ 32），请特别注意，因为主机，4、2和1的网络在某些边缘情况下，具体情况取决于您要解决的确切问题

5

IP：128.42.5.4

``````      32768     16384  8192  4096  2048  1024   512   256  ----> Binary
128       192   224   240   248   252   254   255  ----> Sunet Mask
/17       /18   /19   /20   /21   /22   /23   /24  ----> CIDR
32766     16382  8190  3094  2046  1022   510   254  ----> Host

128     64    32     16     8     4    2     1   ----> Binary
128    192   224    240   248   252   254   255  ----> Sunet Mask
/25    /26   /27    /28   /29   /30   /31   /32  ----> CIDR
126     62    30     14     6     2    *     -   ----> Host

128        64        32       16        8         4         2        1
10000000   01000000  00100000 00010000  00001000  00000100  00000010   00000001
``````

``````   Example
Network=192.168.1.0 /24;
Network Address with Subnet mask =  192.168.1.0 subnet 255.255.255.0
Ip address range 192.168.1.0----192.168.1.255
Fist available ip address  192.168.1.1;
Last available ip address  192.168.1.254;
Broadcast address = 192.168.1.255;
254 Host
``````

``````   Network=192.168.1.0 /25;
Network Address with Subnet mask =  192.168.1.0 subnet 255.255.255.128
Ip address range 192.168.1.0----192.168.1.128
Fist available ip address  192.168.1.1;
Last available ip address  192.168.1.126;
Broadcast address = 192.168.1.127;
126 Hosts
``````

``````   When the CIDR increased ex. /24. /25.  the network will divided by the
binary number.
/25  increase network   0-128| 128- 256 |                   you will have 2 Networks
/26  increase network   0-64 | 64 - 128 | 128-192 | 192-256 you will have 4 Networks
.
.
.
/32......
``````
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.