Learning about IP addresses and subnetting requires mastering binary and decimal conversions; in order to quickly determine whether an address is available and which network segments can be merged, you also need to master some of the laws of binary numbers.

There are two major versions of IP addresses: IPv4 and IPv6. IP addresses in this chapter specifically refer to IPv4, which is a 32-bit binary number and is divided into a network part and a host part. The subnet mask is used to determine which bits are the network part and which bits are the host part. A gateway functions as a network segment’s exit to other network segments and is the interface address of the Layer 3 device connected to that network segment.

IP addresses can be divided into five classes, namely Class A, B, C, D, and E.

IP addresses can be further categorized into public addresses and private addresses. Public addresses are planned and assigned globally and cannot overlap with each other. Private addresses are used within the campus network. Network address translation (NAT) is required to access the public network using private addresses.

All public IPv4 addresses have already been assigned, so in order to make full use of public IP addresses and avoid waste, a large network segment can be divided into multiple subnets, and appropriate subnets can be assigned according to the number of computers. Both fixed length subnetting or variable length subnet division are available.

Contrary to subnetting, if there are too many computers in a network segment and a lot of network segments need to be assigned addresses, multiple consecutive network segments can be merged into a large one by reducing the number of 1s in the subnet mask.

4.1 Preliminary Knowledge

All IP addresses of computers and network device interfaces in the network are 32-bit binary numbers. The process of learning IP addresses and subnetting later requires converting binary numbers to decimal numbers and also decimal numbers to binary numbers. Therefore, before learning IP address and subnetting, the readers should first learn about the knowledge of binary system, and are required to familiarize themselves with the relationship between binary and decimal numbers as described below.

4.1.1 Binary System and Decimal System

In learning subnetting, when readers see subnet mask in decimal, they are required to quickly determine how many 1s there will be when the subnet mask is written in binary; and when they see a subnet mask in binary, they shall also proficiently write the corresponding subnet mask in decimal.

Binary system is a numeral system widely used in computer technology. Binary data is a number represented by two digits, 0 and 1. It is a base-2 numeral system where 1 + 1 = 0 (with a carry to the adjacent left bit) and 0 − 1 = 1 (borrow 1 from the adjacent bit to the left). Almost all numeral systems used in current computer systems are a binary system.

Readers are suggested to remember the following list of binary and decimal correlation. In fact, there is no need for rote learning, as there are rules to follow. As follows, when the 1 in binary shifts one bit to the left, the corresponding decimal is multiplied by 2.

Binary number

Decimal number

1

1

10

2

100

4

1000

8

10 000

16

10 0000

32

100 0000

64

1000 0000

128

You should also remember the correlation between binary and decimal numbers listed below. The requirement is that: when one of the decimal numbers below is given, the reader can immediately write the corresponding binary number; and when one of the binary numbers below is given, the reader can immediately write the corresponding decimal number.

Binary number

Decimal number

 

1000 0000

128

 

1100 0000

192

It shall be remembered like this: 1000 0000 + 100 0000, that is 128 + 64 = 192.

1110 0000

224

It shall be remembered like this: 1000 0000 + 100 0000 + 10 0000, that is, 128 + 64 + 32 = 224.

1111 0000

240

It shall be remembered like this: 128 + 64 + 32 + 16 = 240.

1111 1000

248

It shall be remembered like this: 128 + 64 + 32 + 16 + 8 = 248.

1111 1100

252

It shall be remembered like this: 128 + 64 + 32 + 16 + 8 + 4 = 252.

1111 1110

254

It shall be remembered like this: 128 + 64 + 32 + 16 + 8 + 4 + 2 = 254.

1111 1111

255

It shall be remembered like this: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.

It can be seen that when the eight-digit binary number is consisted of all 1s, it is 255 in decimal.

In case you forget the above correlation, you can remember it by its rule. As shown in Fig. 4.1, by remembering a few key points on the number axis, you can immediately figure out the correlation. Draw a line, and the left end represents the binary number 0000 0000, while the right end represents the binary number 1111 1111. You can see that there are a total of 256 numbers from 0 to 255, the middle of which is 128. 128 corresponds to the binary number 1000 0000, which is a demarcation point. For numbers before 128, the leftmost digit of their corresponding binary number is 0, while for numbers after 128, the leftmost digit of their corresponding binary number is 1.

Fig. 4.1
figure 1

Correlation between binary numbers and decimal numbers

The number in the middle of 128 to 255 is 192, and the corresponding binary number is 1100 0000, which means that starting from 192, the leftmost two bits of the binary number of the number are 1.

The number in the middle of 192 to 255 is 224, and the corresponding binary number is 1110 0000, which means that starting from 22, the leftmost three bits of the binary number of the number are 1.

In this way it is easy to find that the number in the middle of 0 to 128 is 64, and the corresponding binary number is 100 0000. The number in the middle of 0 to 64 is 32, and the corresponding binary number is 10 0000.

In this way, even if you forget the above correlation, you can quickly find the correlation between binary and decimal numbers by drawing a number axis and following the above method.

4.1.2 Rules for Converting Decimal Numbers to Binary Numbers

When learning to merge network segments later, you need to determine whether the given subnets can be merged into a single network segment, a process that requires the readers to be able to converting a decimal number into a binary number and write the last few digits of the converted binary number. The correlation between decimal and binary numbers is shown in Table 4.1.

Table 4.1 Correlation between decimal and binary numbers

By using the correlation between decimal and binary numbers in Table 4.1, the following rules can be found.

  1. 1.

    If a number can be divided by 2, when it is written in binary, its last digit is 0. If the remainder is 1, then the last digit is 1.

  2. 2.

    If a number can be divided by 4, when it is written in binary, its last two digits are 00. If the remainder is 2, then 2 is written in binary form, so the last two digits are 10.

  3. 3.

    If a number can be divided by 8, when it is written in binary, its last three digits are 000. If the remainder is 5, then 5 is written in binary form, so the last three digits are 100.

  4. 4.

    If a number can be divided by 16, when it is written in binary, its last four digits are 0000. If the remainder is 6, then 6 is written in binary form, so the last four digits are 0110.

Based on the above rules, it can be seen that when converting a decimal number into a binary number, for the last n digits of the binary number, it can be determined by dividing the number by 2n and writing the remainder as an n-digit binary number.

Based on the previous rules, convert decimal number 242 to a binary number and write the last four digits of the binary number.

24 = 16, and the remainder of 242 divided by 16 is 2. When the remainder is written as a four-digit binary number, it becomes 0010, which means that when the decimal number 242 is converted into a binary number, the last four digits of the converted binary number is 0010.

4.2 Detailed Explanation of IP Addresses

An IP address is a 32-bit binary address assigned to each host connected to the Internet. IP addresses are used to locate computers and network devices on a network.

4.2.1 MAC Addresses and IP Addresses

Since a computer’s network interface card has a physical address (MAC address), why does it still need an IP address?

As shown in Fig. 4.2, there are three network segments in the network. One switch corresponds to one network segment, and two routers are used to connect these three network segments. MA, MB, MC, MD, ME, MF, and M1, M2, M3 and M4 in Fig. 4.2 represent the MAC addresses of the computer and router interfaces, respectively.

Fig. 4.2
figure 2

The role of MAC addresses and IP addresses

If Computer A wants to send a packet to Computer F, it must add a source IP address (10.0.0.2) and a destination IP address (12.0.0.2) to the packet at the network layer.

For that packet to reach Computer F, it has to be forwarded by Router 1. So how can the packet be encapsulated in order for Switch 1 to forward it to Router 1? The answer is that the MAC address needs to be added at the data link layer with the source MAC address of MA and the target MAC address of M1.

Router 1 receives the packet and needs to forward it to Router 2, which requires re-encapsulating the packet into a frame with a target MAC address of M3 and a source MAC address of M2.

The packet arrives at Router 2 and needs to be re-encapsulated with a target MAC address of MF and a source MAC address of M4. Switch 3 forwards the frame to Computer F.

As can be seen from Fig. 4.2, the destination IP address of the packet determines which computer the packet eventually arrives at, while the destination MAC address determines which device the next hop of the packet, which is not necessarily the destination.

If the global computer network were one large Ethernet network, then IP addresses would no longer be needed for communication, and only MAC addresses would be enough. Imagine what that would be like. When one computer sends a broadcast frame, all computers around the world can receive it, and if they all have to process it, the bandwidth of the entire network will be exhausted by the broadcast frame. Therefore, a Layer 3 device (a router or Layer 3 switch) must also be used to isolate the Ethernet broadcasts. By default, routers do not forward broadcast frames, and they only forward packets between different networks.

4.2.2 Composition of IP Addresses and Gateways

Before explaining the composition of IP addresses, let’s introduce telephone numbers that everyone knows to understand the composition of IP addresses by telephone numbers.

A telephone number consists of an area code and a local number. As shown in Fig. 4.3, the area code is 0311 for Shijiazhuang, 010 for Beijing, and 0312 for Baoding. Telephone numbers in the same area have the same area code, and there is no need to dial the area code for local calls, which is only needed for long-distance calls.

Fig. 4.3
figure 3

Area codes

Similar as a phone number, an IP address of a computer also consists of two parts: one part is the network ID; and the other is the host ID. As shown in Fig. 4.4, computers in the same network segment have the same network part. Routers connect different network segments and are responsible for forwarding data between them; and switches connect computers on the same network segment.

Fig. 4.4
figure 4

Network IDs, host IDs and gateways

In addition to configuring IP addresses and subnet masks for computers, you also have to configure gateways for them. A gateway is an exit for the computer to send packets to computers in other network segments, which is the address of the router (or Layer 3 device) interface. In order to avoid address conflicts with computers in the network, the gateway usually uses the first available address or the last available address of the network segment, and the subnet mask is also required to configure the IP address for the router interface.

Before a computer communicates with other computers, it must first determine whether the destination IP address and its own IP address are in the same network segment. If they are in the same network segment, the destination MAC address of the frame is the MAC address of the destination host; if not, the destination MAC address of the frame is the MAC address of the gateway.

4.2.3 Format of IP Addresses

According to the TCP/IPv4 protocol stack, an IP address is represented by a 32-bit binary number, that is, 32 bits, which is four bytes when converted into bytes. For example, an IP address in binary is “10101100000100000001111000111000”, which is too long for people to process. To make it easier to use, such a long address is divided into four parts, each part eight bits long in binary, separated by the symbol “.”. The four-part binary IP address 10101100.00010000. 00011110.00111000 is often written in decimal, so the IP address can be represented as “172.16.30.56”. This notation of IP addresses is called “dotted decimal notation”, which is obviously easier to remember than the combination of 1s and 0s.

The dotted decimal notation of IP addresses simplifies writing and memorization, so it is generally used when configuring IP addresses for computers, as shown in Fig. 4.5. In this book, these four parts of the IP address are numbered to facilitate description, which are called part 1, part 2, part 3 and part 4 from left to right.

Fig. 4.5
figure 5

The dotted decimal notation

The eight-bit binary number 11111111 is 255 when converted to a decimal number, so the maximum number of each part represented by the dotted decimal notation cannot exceed 255. After configuring the IP address for the computer, you also need to configure the subnet mask and gateway.

4.2.4 Subnet Masks of IP Addresses

A subnet mask, also known as a network mask, is used to specify which bits of an IP address are the network part and which are the host part. The subnet mask has only one function, which is to divide a certain IP address into network part and host part.

There are two ways to represent the subnet mask, which are described below.

  1. 1.

    By the dotted decimal notation with the same format as the IP address, such as 255.0.0.0 or 255.255.255.128.

  2. 2.

    By adding the symbol “/” and numbers from 1 to 32 to the end of the IP address. The numbers 1 to 32 indicate the length of the network ID bits in the subnet mask, for example, the subnet mask 192.168.1.1/24 can also be expressed as 255.255.255.0, and the subnet mask 192.168.1.1/16 can be expressed as 255.255.0.0.

As shown in Fig. 4.6, the IP address of the computer is 131.107.41.6, the subnet mask is 255.255.255.0, and the computer is in the network segment 131.107.41.0/24. If the host part becomes all 0s, it is the network segment in which the host is located. When this computer communicates with a remote computer, as long as the first three parts of the remote computer’s IP address are 131.107.41, the two computers are considered to be in the same network segment. For example, this computer is in the same network segment as the computer with IP address 131.107.41.123, but not in the same network segment as the computer with IP address 131.107.42.123, because they do not share the same network part.

Fig. 4.6
figure 6

The function of subnet mask (1)

As shown in Fig. 4.7, the IP address of the computer is 131.107.41.6, the subnet mask is 255.255.0.0, and the computer is in the network segment 131.107.0.0/16. When it communicates with a remote computer, as long as the first two parts of the IP address of the remote computer are 131.107, the two computers are considered to be in the same network segment. For example, the computer is in the same network segment as the computer with IP address 131.107.42.123, but not in the same network segment as the computer with IP address 131.108.42.123, because they do not share the same network part.

Fig. 4.7
figure 7

The function of subnet mask (2)

As shown in Fig. 4.8, the IP address of the computer is 131.107.41.6, the subnet mask is 255.0.0.0, and the computer is in network segment 131.0.0.0/8. When this computer communicates with a remote computer, as long as the first part of the remote computer’s IP address is 131, the two computers are considered to be in the same network segment. For example, the computer is in the same network segment as the computer with IP address 131.108.42.123, but not in the same network segment as the computer with IP address 132.108.42.123, because they do not share the same network part.

Fig. 4.8
figure 8

The function of subnet mask (3)

So how does a computer use a subnet mask to calculate which network segment it is on?

As shown in Fig. 4.9, a computer’s IP address is configured as 131.107.41.6 and its subnet mask is 255.255.255.0. Write both its IP address and subnet mask in binary, and perform the “AND” operation on the corresponding binary bits of these two binary numbers, and it will get 1 only if both digits are 1, otherwise it will get 0. In other words, after the “AND” operation, 1 and 1 arrives at 1, while 0 and 1, 1 and 0, 0 and 0 arrives at 0. Therefore, after the IP address and subnet mask finish the “AND” operation, the host part will be zero regardless of the value, and the network part will remain unchanged, so that the computer is in the network segment 131.107.41.0/24.

Fig. 4.9
figure 9

The function of subnet mask (4)

Subnet masks are very important, and will lead to computer communication failure if incorrectly configured. When a computer communicates with other computers, it first determines whether it is in the same network segment as the destination address. First, an AND operation is performed on its subnet mask and IP address to learn about its network segment, then an operation is performed on its subnet mask and the destination address to see if the network part observed is the same as the network segment it is in. If the part address is not the same, they are not in the same network segment, so the MAC address of the gateway is used as the destination MAC address when encapsulating the frame and the switch forwards the frame to the router interface; if it is the same, the MAC address of the destination IP address is used to encapsulate the frame, and the frame is directly sent to the destination IP address.

As shown in Fig. 4.10, the router is connected to two network segments “131.107.41.0 255.255.255.0” and “131.107.42.0 255.255.255.0”, and the computers in the same segment have the same subnet mask. The gateway of the computer is the exit to the other network segment, which is the router interface address. The address used for the router interface can be any address in the network segment, but usually the first available address or the last available address in the segment is used, in order to avoid conflicts with other computer addresses in the network as much as possible.

Fig. 4.10
figure 10

The function of subnet masks and gateways

If a computer is not configured with a gateway, it will not know which is the router interface in cross-network segment communication and will not know which device is the target for the next hop. Therefore, for a computer to communicate across network segments, a gateway must be specified.

As shown in Fig. 4.11, Computer A and Computer B, which are connected to the switch, have different subnet mask settings, and neither of them has set a gateway. Think about it. Is Computer A able to communicate with Computer B? Note: only when the packets can be sent and returned will the network be considered connected.

Fig. 4.11
figure 11

Different subnet mask settings (1)

Answer: Computer A performs an “AND” operation with its own subnet mask to learn that it is in network segment 131.107.0.0/16, and the destination address 131.107.41.28 also belongs to network segment 131.107.0.0/16. Computer A sends a packet directly to Computer B, and Computer B returns a packet to Computer A. Computer B is in network segment 131.107.41.0/24, and the destination address 131.107.41.6 also belongs to network segment 131.107.41.0/24, so Computer B is also able to send the packet directly to Computer A. Therefore, Computer A is able to communicate with Computer B.

As shown in Fig. 4.12, Computer A and Computer B, which are connected to the switch, have different subnet mask settings, and their IP addresses are as shown in the figure. Neither Computer A nor B has set a gateway. Think about it. Is Computer A able to communicate with Computer B?

Fig. 4.12
figure 12

Different subnet mask settings (2)

Answer: Computer A performs an “AND” operation with its own subnet mask to learn that it is in network segment 131.107.0.0/16, and the destination address 131.107.41.28 also belongs to network segment 131.107.0.0/16. Computer A sends the packet directly to Computer B. When Computer B returns a packet to Computer A, it calculates which network segment it is in using its own subnet mask, and learns that it is in network segment 131.107.41.0/24. Since the destination address 131.107.41.6 does not belong to network segment 131.107.41.0/24, Computer B thinks that it is not in the same network segment as Computer A, so it needs to send the packet to the gateway. Because no gateway is set, it is not possible for Computer B to send packets to Computer A. Therefore, Computer A can send packets to Computer B, but Computer B cannot return packets, thus the network is not working.

4.2.5 Classification of IP Addresses

When the Internet was first designed, the Internet Council defined five types of IP addresses to suit networks of different capacities. IPv4 addresses are 32-bit binary numbers divided into network IDs and host IDs. As for which bits are network IDs and which are host IDs, they are initially identified using the first part of the IP addresses. This means that as soon as you see the first part of the IP address, you should know its subnet mask. In this way, IP addresses are divided into five classes: Class A, Class B, Class C, Class D and Class E.

  1. 1.

    Class A

    As shown in Fig. 4.13, an IP address is a Class A address if its first bit is 0. The network ID is all 0s, so it cannot be used, and 127 is used as a reserved network segment, so the first part of the Class A address takes a value from 1 to 126.

    The default subnet mask for Class A networks is 255.0.0.0. The second to fourth parts is the host ID, and each part takes the value from 0 to 255, a total of 256 values. If you have learned permutation, you will know that the number of hosts in a Class A network is 256 × 256 × 256 = 1,67,77,216, the range of values being 0 to 1,67,77,215 with 0 also counted as a number. The number needs to be subtracted by 2 for available addresses, because the address whose host ID is all 0s is a network address and cannot be used by computers, while the address whose host ID is all 1s is a broadcast address and also cannot be used by computers. Therefore, the number of available addresses is 16777214. If you send a packet to an address with a host ID of all 1s, the computer generates a broadcast frame and sends it to all computers in the network segment.

  2. 2.

    Class B

    As shown in Fig. 4.14, an IP address is a Class B address if its first two bits are 10. The value of the first part of Class B addresses ranges from 128 to 191.

    The default subnet mask for Class B networks is 255.255.0.0. The third and fourth parts are the host ID, and the maximum number of hosts that can be accommodated in each Class B network is 256 × 256 = 65,536, with a value range of 0 to 65,535. The number of available addresses is 65,534 by removing the addresses with host ID of all 0s and all 1s.

  3. 3.

    Class C

    As shown in Fig. 4.15, an IP address is a Class C address if its first three bits are 110. The first part of the Class C address takes the value from 192 to 223.

    The default subnet mask for a Class C network is 255.255.255.0. The fourth part is the host ID. Each Class C network has 256 address, taking values from 0 to 255. Removing the addresses with host IDs of all 0s and all 1s, the number of available addresses is 254.

    You can use 2n − 2 to calculate the available addresses for a network segment, where n is the number of host bits.

  4. 4.

    Class D

    As shown in Fig. 4.16, an IP address is a Class D address if its first four bits are 1110. The values for the first part of a Class D address ranges from 224 to 239. A Class D address is a multicast address. A multicast address does not have a subnet mask, and can only be used as the destination address. We hope that the readers can remember the range of multicast addresses because in addition to broadcasts, some viruses may also send multicast packets in the network, and when using packet capture tools to troubleshoot the network, you must be able to determine whether the captured packets are multicast or broadcast packets.

  5. 5.

    Class E

    As shown in Fig. 4.17, an IP address is a Class E address if its first four bits are 1111. Class E addresses do not distinguish between network ID and host ID. Its first part takes a value range from 240 to 254 and is reserved for future use. Class D and E addresses are not discussed in this book.

    In order to conveniently remember the demarcation points of Class A, Class B, Class C, Class D, and Class E addresses, observe Fig. 4.18 and draw the first part of IP addresses as a numeric axis with values from 0 to 255, and the value ranges of Class A, B, C, D, E addresses are clear.

Fig. 4.13
figure 13

Network ID and host ID of Class A address

Fig. 4.14
figure 14

Network ID and host ID of Class B address

Fig. 4.15
figure 15

Network ID and host ID of Class C address

Fig. 4.16
figure 16

Class D address

Fig. 4.17
figure 17

Class E address

Fig. 4.18
figure 18

A chart to help remember IP address classification

4.2.6 Special IP Addresses

Some IP addresses are reserved for certain purposes, and network administrators cannot assign these addresses to computers. The following lists these addresses that are excluded and explains the reason why they should be reserved.

  • Addresses with host IDs of all 0s are network addresses, such as “192.168.10.0 255.255.255.0”, which refers to network segment 192.168.10.0/24.

  • Addresses with host IDs of all 1 address are broadcast addresses, which specifically refer to all hosts in the network segment. If a computer sends a packet using the IP address with a host ID of all 1s and the data link layer address with the broadcast address FF-FF-FF-FF-FF-FF, the computer name resolution of the same network segment will need to send a broadcast packet for name resolution. For instance, if a computer, whose IP address is 192.168.10.10 and subnet mask is 255.255.255.0, sends a broadcast packet, e.g., the destination IP address is 192.168.10.255, and the frame’s destination MAC address is FF-FF-FF-FF-FF-FF, then all computers in the segment can receive it.

  • 127.0.0.1 is the loopback address, which refers to the local address and is generally used for testing. The loopback address (127.0.0.1) is the IP address inside the host IP stack, mainly used for network software testing and inter-process communication of the local machine. For whatever program, once the data is sent using the loopback address, the protocol software immediately returns the data without any network transmission. Any computer can use this address to access its own shared resources or websites. If you can ping this address, it means that the computer’s TCP/IPv4 stack is working properly. Even if the computer does not have a network interface card, ping 127.0.0.1 shall still work.

  • 169.254.0.0: 169.254.0.0 to 169.254.255.255 are actually automatic private IP addresses. In operating systems before Windows 2000, if a computer could not obtain an IP address, it was automatically configured as “IP address: 0.0.0.0” and “subnet mask: 0.0.0.0”, so it could not communicate with other computers. For Windows 2000 and later operating systems, it is automatically configured as “IP address: 169.254.x. x” and “subnet mask: 255.255.0.0” when it cannot obtain an IP address. In this way, all computers that fail to obtain an IP address can communicate with each other, as shown in Figs. 4.19 and 4.20.

  • 0.0.0.0: If the IP address of the computer conflicts with the addresses of other computers in the network, by using the ipconfig command, you can see the IP address is 0.0.0.0, and the subnet mask is also 0.0.0.0, as shown in Fig. 4.21.

Fig. 4.19
figure 19

Obtain address automatically

Fig. 4.20
figure 20

IP address automatically configured by Windows

Fig. 4.21
figure 21

Address conflict

4.3 Public Addresses and Private Addresses

Computers on the Internet use IP addresses that are globally planned, which are called public addresses. Private addresses are usually used and reserved on intranets such as businesses and schools.

4.3.1 Public Addresses

There are millions of hosts on the Internet, all of which need to use IP addresses for communication, so it is required that IP address blocks used by ISPs at all levels in each country accessing the Internet must not overlap, and an organization is required for unified address planning and assignment for the Internet. These globally unique addresses that are uniformly planned and assigned are called public addresses.

Internet Network Information Center (InterNIC) is responsible for the assignment and management of public addresses. The ISPs at all levels need to apply to InterNIC for public addresses, which are issued by InterNIC in a unified manner, so as to ensure that the address blocks do not conflict.

It is because IP addresses are under unified planning and assignment, as long as the IP address is known, it is easy to find out which ISP in which city the address belongs to. If a website is attacked from a certain address, the city where the attacker is located and the carrier it belongs to can be known by the following way.

As shown in Fig. 4.22, if you type in an IP address on Baidu, you can find out the carrier and location of this IP address.

Fig. 4.22
figure 22

View the carrier and location of the IP address

4.3.2 Private Addresses

Private IP addresses are created simultaneously with the IP addressing scheme. These addresses can be used for private networks and are not available on the Internet, nor do routers on the Internet have routes to private addresses. These private addresses are not accessible on the Internet, and in this respect, computers using private addresses are more secure and can also effectively save public IP addresses.

Intranets of different enterprises or schools can use the same private address. Reserved private IP addresses are listed below.

  • Class A: 10.0.0.0 255.0.0.0, only one Class A network is reserved.

  • Class B: 172.16.0.0 255.255.0.0 to 172.31.0.0 255.255.0.0, a total of 16 Class B networks are reserved.

  • Class C: 192.168.0.0 255.255.255.0 to 192.168.255.255.0 255.255.255.0, a total of 256 Class C networks are reserved.

You can choose which class of private address to use depending on the number of computers in the enterprise or school intranet and the size of the network. If the company currently has seven departments, each with no more than 200 computers, you can consider using the reserved Class C private addresses. If the network is large in scale, for example, when planning a network for Shijiazhuang Municipal Education Commission to connect Shijiazhuang Municipal Education Commission with hundreds of primary and secondary schools in the Shijiazhuang area, the reserved Class A private address shall be selected. It is suggested to use network address 10.0.0.0 and a subnet mask with “/24”, which can provide 65,536 subnets, and each network is allowed to have 254 hosts, leaving the school with a large number of addresses to choose from.

4.4 Subnetting

4.4.1 Why Is Subnetting Needed

The protocol used on the Internet today is the TCP/IPv4 protocol stack. IPv4 addresses are 32-bit binary numbers. If they could all be assigned to computers, there would a total of 232 = 4,294,967,296 (about 4 billion) available addresses. With the removal of Class D and Class E addresses, and the reserved private addresses, the public addresses that can be used on the Internet are becoming more and more limited. Besides, everyone needs to use more than one address, as now both smartphones and smart appliances need IP addresses to access the Internet. By now there are no more available IPv4 public addresses to be assigned to new networks.

In the stage of coexistence of IPv4 and IPv6 when IPv6 is not yet fully used in the Internet, IPv4 public address resources are getting increasingly scarce, so the subnetting technology mentioned in this chapter is required to make full use of IP addresses and reduce address waste.

As shown in Fig. 4.23, according to the traditional classification of IP addresses, there are 200 computers in a network segment, and a Class C network “212.2.3.0 255.255.255.0” is assigned, with the available addresses ranging from 212.2.3.1 to 212.2.3.254. Although not all of these addresses are used, this situation is not considered a waste. Usually, some extra IP addresses are reserved during the network planning, so that there will still be IP addresses to assign if new computers are connected.

Fig. 4.23
figure 23

Address waste

If there are 400 computers in a network and a Class C network is assigned, then the addresses are insufficient. If a Class B network “131.107.0.0 255.255.0.0” is assigned, the addresses available for the Class B network range from 131.107.0.1 to 131.107. 255.254, a total of 65,534 available addresses, which results in a huge waste. Therefore, subnetting is needed to break the address blocks limited by the classification of IP addresses, so that the number of IP addresses and the number of computers in the network can be better matched.

Subnetting means to borrow host bits from existing network segments as subnet bits and making multiple subnets. The tasks of subnetting include the following two.

  • Determine the length of the subnet mask.

  • Determine the first and the last available IP address in the subnet.

There are FLSM (fixed length subnet masks) subnetting and VLSM (variable length subnet masks) subnetting, and fixed subnetting is first introduced in the following part.

4.4.2 FLSM Subnetting

FLSM subnetting is to equally divide a network segment into multiple segments, that is, into multiple equal-size subnets.

  1. 1.

    Equally divide the network into two subnets.

    The following is an example of a Class C network divided into two subnets to explain the process of subnetting.

    As shown in Fig. 4.24, a company has two departments, with 100 computers in each department, and is connected to the Internet through the router. These 200 computers are assigned a Class C network 192.168.0.0, the subnet mask of the network segment is 255.255.255.0, and the router interface uses the first available IP address of this segment, 192.168.0.1.

    For security reasons, it is planned is to divide the computers in these two departments into two network segments, separated by a router. The number of computers has not increased, which is still 200, so a Class C IP address is sufficient. Now “192.168.0.0 255.255.255.0”, the Class C network, is divided into two subnets.

    As shown in Fig. 4.25, the fourth part of the IP address is written in binary, and the subnet mask is represented using two ways: binary and decimal numbers. The subnet mask is shifted one bit to the right (that is, the number of 1s in the subnet mask is increased by one) so that the first bit of the host ID of the Class C address becomes a network bit. If this bit is 0, it is Subnet A, and if this bit is 1, it is Subnet B.

    As shown in Fig. 4.25, for the fourth part of the IP address, if its value is between 0 and 127, its first bit is 0; and if its value is between 128 and 255, its first bit is 1. Divide it into two subnets, A and B, with 128 as the demarcation point. Now the number of 1s in the subnet mask becomes 25, which is 255.255.255.128 when written in decimal. The subnet mask is shifted by one bit to the right (i.e., the number of 1s in the subnet mask increases by 1), and two subnets are made.

    Both Subnet A and Subnet B have a subnet mask of 255.255.255.128.

    Subnet A can use addresses from 192.168.0.1 to 192.168.0.126. Since the host bits of IP address 192.168.0.0 are all 0s, it is the network address of the network segment, so it cannot be assigned to the computer for use. As shown in Fig. 4.26, Since the host bits of IP address 192.168.0.127 are all 1s, it is the broadcast address of this network segment, so it also cannot be assigned to the computer.

    Subnet B can use addresses from 192.168.0.129 to 192.168.0.254. IP address 192.168.0.128 is the network address, so it cannot be assigned to computers for use, while IP address 192.168.0.255 is the broadcast address, and also cannot be assigned to computers.

    The address planning after the network is divided into two subnets is as shown in Fig. 4.27.

  2. 2.

    Equally divide the network into four subnets.

    Assume the company has four departments, with 50 computers in each department, and now it uses the Class C network 192.168.0.0/24. From security considerations, it is planned to allocate computers of each department to different network segments, which requires the Class C network “192.168.0.0 255.255.255.0” to be divided into four subnets. Then how to divide it into four subnets?

    As shown in Fig. 4.28, write the fourth part of the IP address of the network segment “192.168.0.0 255.255.255.0” in binary. If the network is to be divided into four subnets, you need to move the subnet mask two bits to the right, so that the first and second bits become network bits, and the network can be divided into four subnets. If the first two bits are 00, then it is Subnet A; if the first two bits are 01, then it is Subnet B; if the first two bits are 10, then it is Subnet C; if the first two bits are 11, then it is Subnet D.

    The subnet masks for Subnet A, B, C, and D are all 255.255.255.192.

    The addresses available for Subnet A are 192.168.0.1 to 192.168.0.62.

    The addresses available for Subnet B are 192.168.0.65 to 192.168.0.126.

    The addresses available for Subnet C are 192.168.0.129 to 192.168.0.190.

    The addresses available for Subnet D are 192.168.0.193 to 192.168.0.254.

Note

As shown in Fig. 4.29, the last address of each subnet is the broadcast address of this subnet and cannot be assigned to a computer for use, for example, 63 of Subnet A, 127 of Subnet B, 191 of Subnet C, and 255 of Subnet D.

Fig. 4.24
figure 24

The situation of a network segment

Fig. 4.25
figure 25

Equally divide the network into two subnets

Fig. 4.26
figure 26

Network part and host part

Fig. 4.27
figure 27

The address planning after subnetting

Fig. 4.28
figure 28

Equally divide the network into four subnets

Fig. 4.29
figure 29

Network part and host part

  1. 3.

    Equally divide the network into eight subnets.

    If you want to equally divide a Class C network into eight subnets, as shown in Fig. 4.30, the subnet mask needs to be shifted three bits to the right for the eight subnets, and the first, second and third bits become network bits.

    The subnet mask is the same for each subnet and is 255.255.255.224.

    The addresses available for Subnet A are 192.168.0.1 to 192.168.0.30.

    The addresses available for Subnet B are 192.168.0.33 to 192.168.0.62.

    The addresses available for Subnet C are 192.168.0.65 to 192.168.0.94.

    The addresses available for Subnet D are 192.168.0.97 to 192.168.0.126.

    The addresses available for Subnet E are 192.168.0.129 to 192.168.0.158.

    The addresses available for Subnet F are 192.168.0.161 to 192.168.0.190.

    The addresses available for Subnet G are 192.168.0.193 to 192.168.0.222.

    The addresses available for Subnet H are 192.168.0.225 to 192.168.0.254.

Note

Addresses whose host bits are all 0s and all 1s should be left out, and the remaining addresses are the host IP addresses that each subnet can used. As shown in Fig. 4.30, 31, 63, 95, 127, 159, 191, 223, and 255 are the broadcast addresses of the corresponding subnets. Each subnet is the \( \frac{1}{2} \)×\( \frac{1}{2} \)×\( \frac{1}{2} \)of the original size, that is, three \( \frac{1}{2} \), so the subnet mask is shifted three bits to the right.

Fig. 4.30
figure 30

Equally divide the network into eight subnets

Summary: if a subnet address block is \( {\left(\frac{1}{2}\right)}^n \) the size of the original network segment, the subnet mask is shifted n bits to the right on the basis of the original network segment.

4.4.3 Examples of FLSM Subnetting

The previous section explains the FLSM subnetting using a Class C network, and the summarized rule is also applicable to the subnetting of Class B networks. However, it is easy to make mistakes if you are not familiar with the rule, so when subdividing a network, it is best to write the host bits in binary form and determine the subnet mask as well as the first and last address that each subnet can use.

As shown in Fig. 4.31, network “131.107.0.0 255.255.0.0” is equally divided into two subnets. The network can be divided into two subnets by moving the subnet mask one bit to the right.

Fig. 4.31
figure 31

Subnetting of Class B network

The subnet masks of the two equal-size subnets are both 255.255.128.0.

First determine the first and the last available address of Subnet A. When you are not familiar with it, it is better to write the host part in binary as it is shown in Fig. 4.32. The host bits cannot be all 0s or all 1s. And then write the first and the last available address according to the binary number.

Fig. 4.32
figure 32

Address range of Subnet A

The first available address of Subnet A is 131.107.0.1 and the last is 131.107.127.254. Think about it. Can the address 131.107.0.255 of Subnet A be assigned to a computer for use? Writing the host bits in binary shows that not all host bits are 1 so it can be used by the computer.

As shown in Fig. 4.33, the first available address of Subnet B is 131.107.128.1, and the last is 131.107.255.254.

Fig. 4.33
figure 33

Address range of Subnet B

Although this method takes many steps, it can prevent making mistakes. When you have familiarized yourself with it, you can directly write the first and last address of the subnet.

4.4.4 VLSM Subnetting

The above mentioned subnetting is to equally divide a network segment into multiple subnets. If the number of computers in each subnet is not the same, it is necessary to divide the network segment into subnets with different address spaces, which is VLSM subnetting. The following is an example for VLSM subnetting.

As shown in Fig. 4.34, there is a Class C network “192.168.0.0 255.255.255.0” that needs to be divided into five network segments in order to meet the following network requirements: The network has three switches, each connected to 20 computers, 50 computers and 100 computers, respectively; the connection interfaces between routers also need addresses, and although there are only two addresses, they also need to occupy a network segment, so that there are a total of five network segments in the network.

Fig. 4.34
figure 34

VLSM subnetting

As shown in Fig. 4.34, draw a numerical axis for the host bits 0 to 255 of “192.168.0.0 255.255.255.0”, the addresses from 128 to 255 are appropriate for network segment C with 100 computers. The address range of this subnet is \( \frac{1}{2} \) of the original network, and the subnet mask is moved one bit to the right, which is 255.255.255.128 in decimal. The first available address is 192.168.0.129, and the last is 192.168.0.254.

The addresses from 64 and 127 are appropriate for network segment B with 50 computers. The address range of the subnet is \( \frac{1}{2}\times \frac{1}{2} \) of the original, and the subnet mask is shifted to the right by two bits, which is 255.255.255.192 in decimal. The first available address is 192.168.0.65, and the last is 192.168.0.126.

The addresses from 32 and 63 are suitable for network segment A with 20 computers, the address range of the subnet is \( \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2} \) of the original, and the subnet mask is moved three bits to the right, which is 255.255.255.224 in decimal. The first available address is 192.168.0.33, and the is 192.168.0.62.

Of course, you can also use the following subnetting scheme: the network segment of 100 computers can use the subnet between 0 and 127, the network segment of 50 computers can use the subnet between 128 and 191, and the network segment of 20 computers can use the subnet between 192 and 223, as shown in Fig. 4.35.

Fig. 4.35
figure 35

Numerical axis of subnetting

Rule: if a subnet address block is \( \frac{1}{2} \) the size of the original network segment, the subnet mask shifts n bits to the right on the basis of the original network segment. For VLSM subnets, subnet masks are different as well.

If two IP addresses are needed in a network, what should the subnet mask be? As you can see in Fig. 4.34, the interfaces connecting the routers also require a network segment and two addresses. Here is a look at how to plan subnetting for network segment D and E in Fig. 4.34.

As shown in Fig. 4.36, D and E is the address blocks of a point to point network. Subnet between 0 to 3 can be given to the two router interfaces in network segment D. The first available address is 192.168.0.1, and the last is 192.158.0.2, while 192.168.0.3 is the broadcast address in the network segment. The subnet masks are shown in Fig. 4.37.

Fig. 4.36
figure 36

The assigned subnets and the remaining subnets

Fig. 4.37
figure 37

Broadcast address

The Subnet 4 to 7 can be given to two router interfaces in network segment E. The first available address is 192.168.0.5, and the last is 192.158.0.6, while 192.168.0.7 is the broadcast address in the network segment, as shown in Fig. 4.38.

Fig. 4.38
figure 38

Broadcast address

Each subnet is \( \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2} \) the size of the original network, that is, \( {\left(\frac{1}{2}\right)}^6 \), and the subnet mask is moved six bits to the right. 111111111.11111111.111111111.11111100 is 255.255.255.252 (or “/30”) when written in decimal.

The final result of subnetting is shown in Fig. 4.36. After careful planning, in addition to satisfying the address requirements of five network segments are satisfied, there are two address blocks remained, i.e., address blocks 8 to 16 and address blocks 16 to 32 are not used.

FLSM and VLSM subnetting shatter the concept of IP address “classes”, so that Internet service providers (ISPs) can flexibly divide large address blocks into appropriate small ones (subnets) for customers to prevent the waste of a large number of IP addresses. At the same time, the subnet mask also elevates the byte limit, and this kind of subnet mask is called Variable Length Subnet Masking (VLSM). The variable length subnet masking is usually expressed in the form of “/n”, such as 131.107.23.32/25, 192.168.0.178/26, and the number after the slash (/) indicates the length of the network identification bits in the subnet mask.

4.5 Merge Subnets

The subnetting described earlier treats the host bits of a network as network bits to divide the network into multiple subnets. In addition, it is also possible to merge multiple networks (subnets) into one large network (subnet) by treating the network bits of multiple networks (subnets) as host bits.

4.5.1 Merge Network Segments

As shown in Fig. 4.39, an enterprise has a network segment with 200 computers; after using network segment “192.168.0.0 255.255.255.0”, the number of computers has increased to 400.

Fig. 4.39
figure 39

Addresses of two network segments

The size of the network can be expanded by adding a switch to the network. At this time, if a Class C IP address is not enough, you can add another Class C address “192.168.1.0 255.255.255.0”. These computers are in the same network segment at the physical level, but the IP addresses are not in the same network segment, that is, they are logically not in the same network segment. If you want these computers to be able to communicate with each other, you can add the addresses of these two Class C networks to the router’s interface as gateways to these two network segments.

In this case, for the communication between Computer A and Computer B, packets have to be forwarded by a router so that the two subnets can communicate. These computers are physically in one network segment, but the packets still need to be forwarded by a router, which is obviously inefficient. Is there a better way to make these two Class C networks of computers think that they are in the same network segment? This requires merging the two Class C networks 192.168.0.0/24 and 192.168.1.0/24.

As shown in Fig. 4.40, after writing the third and fourth parts of the IP addresses of the two network segments in binary, you can see the subnet mask is moved one bit to the left (the number of 1s in the subnet mask is reduced by 1), so the network parts of the two network segments become the same, and the two network segments are in the same network segment.

Fig. 4.40
figure 40

Merge two subnets

The merged network segment is 192.168.0.0/23, and the subnet mask is 255.255.254.0 when written in decimal. The available addresses are from 192.168.0.1 to 192.168.1.254, and the IP addresses of computers in the network and the address configuration of the router interface is shown in Fig. 4.41.

Fig. 4.41
figure 41

The address assignment after the merge

After the merger, IP address 192.168.0.255/23 can be given to the computer for use. The host bits of the address seem to be all 1s, and the address cannot be used by the computer, but after converting the third and fourth parts of the IP address into binary numbers, you can see that the host bits are not all 1s, as shown in Fig. 4.42.

Fig. 4.42
figure 42

Method to determine whether it is a broadcast address

Rule: by shifting the subnet mask one bit to the left, you can merge two consecutive network segments. However, not all consecutive segments can be merged. The following will introduce the rules of merging network segments.

4.5.2 Rules of Merging Network Segments

As mentioned earlier, when the subnet mask is moved one bit to the left, two consecutive network segments can be merged, but not any two consecutive segments can be merged into a network segment by this method.

For example, 192.168.1.0/24 and 192.168.2.0/24 cannot be merged into one network segment by moving the subnet mask one bit to the left. After writing the third and fourth parts of these two network segments into binary, you can see that, as shown in Fig. 4.43, though the subnet mask is moved one bit to the left, the network parts of the two network segments are still different, indicating that the two segments cannot be merged into one network segment.

Fig. 4.43
figure 43

The rule of merging network segments (1)

To merge them into one network segment, the subnet mask should be moved two bits to the left, but if that is done, you are actually merging four network segments, as shown in Fig. 4.44.

Fig. 4.44
figure 44

The rule of merging network segments (2)

The following explains which consecutive network segments (subnets) can be merged, i.e., the rules of merging network segments.

  1. 1.

    Determine whether two subnets can be merged.

    As shown in Fig. 4.45, 192.168.0.0/24 and 192.168.1.0/24 can be merged into a network segment 192.168.0.0/23 by moving their subnet masks one bit to the left.

    As shown in Fig. 4.46, 192.168.2.0/24 and 192.168.3.0/24 can be merged into a network segment 192.168.2.0/23 by moving their subnet masks one bit to the left.

    Rule: when merging two consecutive network segments, if the last bit of the network number of the first segment is 0 when written in binary form, the two segments can be merged. According to the rule described in 4.1.2, as long as a number is divisible by 2, the last bit must be 0 when written in binary form.

    Conclusion: to determine whether two consecutive network segments can be merged, as long as the network number of the first segment is divisible by 2, the two network segments can be merged by shifting their subnet mask one bit to the left.

    Can 131.107.31.0/24 and 131.107.32.0/24 be merged by shifting the subnet mask one bit to the left?

    Can 131.107.142.0/24 and 131.107.143.0/24 be merged by shifting the subnet mask one bit to the left?

    According to the above conclusion, when 31 is divided by 2, the remainder is 1, so 131.107.31.0/24 and 131.107.32.0/24 cannot be merged into one network segment by shifting the subnet mask one bit to the left. When 142 is divided by 2, the remainder is 0, so 131.107.142.0/24 and 131.107.143.0/24 can be merged into one network segment by shifting the subnet mask one bit to the left.

  2. 2.

    Determine whether four network segments can be merged

    As shown in Fig. 4.47, in order to merge four network segments, 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, and 192.168.3.0/24, the subnet mask needs to be shifted two bits to the left.

    You can see that to merge the four network segments 192.168.4.0/24, 192.168.5.0/24, 192.168.6.0/24, and 192.168.7.0/24, the subnet masks need to be moved two bits to the left, as shown in Fig. 4.48.

    Rule: for four consecutive segments, as long as the last two bits of the network number of the first network segment are 00 when written in binary form, these four segments can be merged. According to the law of binary numbers in 4.1.2, as long as a number is divisible by 4, its last two bits must be 00 when written in binary form.

    Conclusion: to determine whether four consecutive network segments can be merged, as long as the network number of the first network segment is divisible by 4, the four segments can be merged by shifting the subnet mask two bits to the left.

    Think about how to determine whether eight consecutive segments can be merged.

Fig. 4.45
figure 45

Merge 192.168.0.0/24 and 192.168.1.0/24

Fig. 4.46
figure 46

Merge 192.168.2.0/24 and 192.168.3.0/24

Fig. 4.47
figure 47

Merge four network segments 1

Fig. 4.48
figure 48

Merge four network segments 2

4.6 Determine Which Network Segment an IP Address Belongs

In the following, we will introduce how to determine which network segment an IP address belongs based on the IP address and subnet mask given. When all host bits are 0, it is the network segment which the IP address belongs to.

Determine which subnet 192.168.0.101/26 belongs to. This is a Class C address, whose subnet mask is 24 bits by default and is now 26 bits. The subnet mask is moved two bits to the right, so according to the above summarized rule, each subnet is \( \frac{1}{2}\times \frac{1}{2} \) the size of the original, that is, this Class C network is equally divided into four subnets. As shown in Fig. 4.49, 101 is located between 64 and 128, and after all host bits are set to 0, it is 64. Therefore, the address belongs to subnet 192.168.0.64/26.

Fig. 4.49
figure 49

Determine which subnet the address belongs to (1)

Determine which subnet 192.168.0.101/27 belongs to. The is a Class C address whose subnet mask is 24 bits by default and is now 27 bits. The subnet mask is moved three bits to the right, so according to the above summarized rule, each subnet is \( \frac{1}{2}\times \frac{1}{2}\times \frac{1}{2} \) the size of the original, that is, this Class C network is equally divided into eight subnets. As shown in Fig. 4.50, 101 is located between 96 and 128, and after all host bits are set to 0, it is 96. Therefore, the address belongs to subnet 192.168.0.96/27.

Fig. 4.50
figure 50

Determine which subnet the address belongs to (2)

Summary: all IP addresses 192.168.0.0 to 192.168.0.63 belong to subnet 192.168.0.0/26; all IP addresses from 192.168.0.64 to 192.168.0.127 belong to the 192.168.0.64/26 subnet; all IP addresses from 192.168.0.128 ~ 192.168.0.191 belong to the subnet 192.168.0.128/26; and all IP addresses from 192.168.0.192 to 192.168.0.255 belong to the subnet 192.168.0.192/26, as shown in Fig. 4.51.

Fig. 4.51
figure 51

The rule to determine which subnet the IP address belongs to

4.7 Exercises

  1. 1.

    (Multi-selection) Which of the following addresses belong to network segment 113.64.4.0/22. ( )

    1. A.

      113.64.8.32

    2. B.

      113.64.7.64

    3. C.

      113.64.6.255

    4. D.

      113.64.5.255

    5. E.

      113.64.3.128

    6. F.

      113.64.12.128

  2. 2.

    (Multi-selection) Which of the following subnets are included in network segment 172.31.80.0/20. ( )

    1. A.

      172.31.17.4/30

    2. B.

      172.31.51.16/30

    3. C.

      172.31.64.0/18

    4. D.

      172.31.80.0/22

    5. E.

      172.31.92.0/22

    6. F.

      172.31.192.0/18

  3. 3.

    A company designs a network that requires 300 subnets, each with a maximum of 50 hosts. To subdivide a Class B network, which of the following subnet masks can be used ( ).

    1. A.

      255.255.255.0

    2. B.

      255.255.255.128

    3. C.

      255.255.255.224

    4. D.

      255.255.255.192

  4. 4.

    (Multi-selection) The network segment 172.25.0.0/16 is divided into eight equal-length subnets, and which of the following addresses belong to the third subnet. ( )

    1. A.

      172.23.78.243

    2. B.

      172.25.98.16

    3. C.

      172.23.72.0

    4. D.

      172.25.94.255

    5. E.

      172.25.96.17

    6. F.

      172.23.100.16

  5. 5.

    (Multi-selection) According to Fig. 4.52, which of the following network segments can be assigned to Network A and Link A. ( )

    1. A.

      Network A: 172.16.3.48/26

    2. B.

      Network A: 172.16.3.128/25

    3. C.

      Network A: 172.16.3.192/26

    4. D.

      Link A: 172.16.3.0/30

    5. E.

      Link A: 172.16.3.40/30

    6. F.

      Link A: 172.16.3.112/30

  6. 6.

    The network part of the IP address is used to identify ( ).

    1. A.

      Router

    2. B.

      Host

    3. C.

      Network interface card

    4. D.

      Network segment

  7. 7.

    Which of the following networks belongs to a private address ( ).

    1. A.

      192.178.32.0/24

    2. B.

      128.168.32.0/24

    3. C.

      172.13.32.0/24

    4. D.

      192.168.32.0/24

  8. 8.

    The maximum number of addresses available in network 122.21.136.0/22 is ( ).

    1. A.

      102

    2. B.

      1023

    3. C.

      1022

    4. D.

      1000

  9. 9.

    The host address 192.15.2.160 is located in the network ( ).

    1. A.

      192.15.2.64/26

    2. B.

      192.15.2.128/26

    3. C.

      192.15.2.96/26

    4. D.

      192.15.2.192/26

  10. 10.

    A company’s network address is 192.168.1.0/24, which is to be divided into five subnets, each with a maximum of 20 hosts. So the applicable subnet mask is ( ).

    1. A.

      255.255.255.192

    2. B.

      255.255.255.240

    3. C.

      255.255.255.224

    4. D.

      255.255.255.248

  11. 11.

    The IP address of a port is 202.16.7.131/26, then the broadcast address of the network where the IP address is located is ( ).

    1. A.

      202.16.7.255

    2. B.

      202.16.7.129

    3. C.

      202.16.7.191

    4. D.

      202.16.7.252

  12. 12.

    In IPv4, multicast addresses are ( ) addresses.

    1. A.

      Class A

    2. B.

      Class B

    3. C.

      Class C

    4. D.

      Class D

  13. 13.

    A host has an IP address of 180.80.77.55 and a subnet mask of 255.255.252.0. The host sends a broadcast packet to its subnet, and the destination address can be ( ).

    1. A.

      180.80.76.0

    2. B.

      180.80.76.255

    3. C.

      180.80.77.255

    4. D.

      180.80.79.255

  14. 14.

    The IP address space of a network is 192.168.5.0/24, if FLSM subnetting is used, and the subnet mask is 255.255.255.248, then the number of subnets divided, the maximum number of addresses that can be assigned in each subnet are ( ).

    1. A.

      32, 8

    2. B.

      32, 6

    3. C.

      8, 32

    4. D.

      8, 30

  15. 15.

    Network segment 192.168.10.0/24 is divided into three subnets, and the number of computers in each segment is shown in Fig. 4.53. Write down first and last addresses that can be used by computers in each segment and their subnet masks.

        First available address  Last available address  Subnet mask

    Segment A _____________   _____________  _____________

    Segment B _____________   _____________  _____________

    Segment C _____________   _____________  _____________

  16. 16.

    Computer A sends a packet to Computer D over two Ethernet frames as shown in Fig. 4.54. Write down the source and destination IP addresses as well as the source and destination MAC addresses of the packets.

  17. 17.

    There are four “/24” address blocks as follows. Write down the maximum possible aggregation: ________________________________.

    212.56.132.0/24   212.56.133.0/24   212.56.134.0/24   212.56.135.0/24

  18. 18.

    As shown in Fig. 4.55, the IP addresses, subnet masks, and gateway settings of Computer A and Computer B are indicated, and the router is connected to two network segments and the Internet. Determine whether Computer A and Computer B in the network can communicate, and whether Computer A and Computer B can access the Web server in the Internet.

  19. 19.

    Based on the network topology and the number of hosts in the network shown in Fig. 4.56, move the IP addresses on the left to appropriate positions.

Fig. 4.52
figure 52

Network topology

Fig. 4.53
figure 53

Subnetting

Fig. 4.54
figure 54

Illustration of the communication between Computer A and Computer D

Fig. 4.55
figure 55

Network topology

Fig. 4.56
figure 56

Network planning