Tips & Tricks
Featured Article: The Newbie's Guide to IP Networking


Networking. Inter, intra, extra. What does it all mean? We don't know, Billy, but we do know this: You have to begin at the beginning. Here's a quick look at IP Networking.

Currently, Ipv4 (which uses 32-bit IP addresses) IP addresses are in use on the Internet. A 32-bit IP address is divided into two parts: the network-prefix and the host-number. Traditionally, each IP address belongs to an IP class. The class breakdown is identified by a self-encoded key in each IP address. For example, if the first bit of an IP address is set to 0 it is considered a Class A IP address; if the first 2 bits are 10 then it is considered to be a Class B IP address, and similarly if the first 3 bits are 110 then it is considered to be a Class C IP address.

Class A IP Networks

Each Class A network address has the highest bit set to 0 and a 7-bit network number followed by a 24-bit host-number. Class A networks are now referred as /8 networks.

Since only the first 8 bits are used in defining the network-prefix, the maximum number of Class A (/8) networks possible are 128. However, 0.0.0.0 (entire IP space or default route) and 127.0.0.0 (loopback network) are special addresses that need to be excluded from the list of valid Class A (/8) networks. This means that there are only 126 (2@sup7 – 2) Class A (/8) networks available.

Each Class A network can have 2@sup24 hosts. However, we need to exclude x.0.0.0 and x.1.1.1 host addresses where x is the 8-bit network-prefix with first bit set to 0. The address with all 0s is considered as the network address, and the one with all 1s is considered the broadcast address. So a total of 16,777,214 (2@sup24 - 2) host addresses are available per Class A (/8) network.

Class B IP Networks

Each Class B network address has the two highest-order bits set to 10. The network-prefix is 14-bit long and the host-number is 16-bit long. A Class B network is referred as a /16 network. A total of 16,384 (2@sup14) networks are possible in Class B, and each of such networks has a possible 65,534 (2@sup16 – 2) hosts.

Class C IP Networks

Each Class C network address has the three highest-order bits set to 110. The network-prefix is 21-bit long and the host-number is 8-bit long. A Class C network is referred as a /24 network. A total of 2,097,152 (2@sup21) networks are possible in Class C, and each such network has 254 (2@sup8 – 2) hosts.

Each of these classes can be summarized as shown in Table A-1.

Table A-1

IP Class Networks

Address Class

Starting IP Address

(in Decimal Dotted Notation)

Ending IP Address

(in Decimal Dotted Notation)

A (/8)

1.xxx.xxx.xxx

126.xxx.xxx.xxx

B (/16)

128.0.xxx.xxx

191.255.xxx.xxx

C (/24)

192.0.0.xxx

223.255.255.xxx

Subnetting IP Networks

Each of the IP classes (A, B, or C) can be broken into smaller networks which are called subnets. When you divide up any of the IP classes into subnets you accomplish two things: (a) you are helping to minimize the routing table for your outmost router and also hiding details of your networked organization. For example, say you have a Class B network, 130.86.32.0. Your router to the Internet is responsible for receiving all IP packets for this entire network. However, once the packets enter your network you can use several subnets to route the IP packets to different divisions of your organization. In the absence of subnetting you would either use a large Class B network or multiple Class C networks to support multiple divisions of your organization. In the latter case the number of routes in your router table will increase, which will effectively slow down the performance of the network.

To create a subnet, you divide the host-number portion of the IP address into a subnet-number and a new host-number. So subnet is a shift from the two-level class hierarchy to a three-level subnet hierarchy. Let’s take a look at an example of subnetting a Class C network called 192.168.1.0. Say that we want to create six subnets for this network in which the largest subnet has 20 hosts.

The very first step is to determine how many bits are necessary to create six subnets from the host-number part, which is 8 bit. Because each bit can be a 1 or a 0, you must divide your subnet along binary boundaries. Therefore, the possible subnets are 2 (2@sup1), 4 (2@sup2), 8 (2@sup3), 16 (2@sup4), 32 (2@sup5), 64 (2@sup6), and 128 (2@sup7). Because we need six subnets, the best choice for us is 8 (2@sup3), which gives us two additional subnets for the future. If we use a 3-bit subnet number we are left with 5 bits in the new host-number. So the maximum subnet mask would be 255.255.255.224 or in binary it would be 11111111. 11111111. 11111111. 11100000. Now the last subnet mask 255.255.255.224 can be also represented as /27, which is called an extended network-prefix. Here we have subnetted a class C (/24) network using /27 (3-bit extended). Table A-2 shows all the subnets for this network.

Table A-2

Subnets of 192.168.1.0/24 Network

Network

(Subnet)

Subnet Mask (Dotted-decimal notation)

Subnet Mask (Binary)

Maximum Hosts

192.168.1.0/27

255.255.255.0

11111111. 11111111. 11111111.00000000

30

192.168.1.32/27

255.255.1.32

11111111. 11111111. 11111111.00100000

30

192.168.1.64/27

255.255.1.64

11111111. 11111111. 11111111.01000000

30

192.168.1.96/27

255.255.1.96

11111111. 11111111. 11111111.01100000

30

192.168.1.128/27

255.255.1.128

11111111. 11111111. 11111111.10000000

30

192.168.1.160/27

255.255.1.160

11111111. 11111111. 11111111.10100000

30

192.168.1.192/27

255.255.1.192

11111111. 11111111. 11111111.11000000

30

192.168.1.224/27

255.255.1.224

11111111. 11111111. 11111111.11100000

30


Still there? Great! Wanna learn more? Even better. This article was excerpted from Red Hat Linux Survival Guide, from the Offical Red Hat Press. Get yourself a copy. You can thank us later.