Make your own free website on Tripod.com

  

        We Engineers move the world

 

Exam Details

Braindump

Favorites

 

Email: Webmaster

 

 

 

 

 

 

Subnetting  Tutorial

IP ADDRESSING

A host is a computer or device, such as a router, on a TCP/IP network.

Every TCP/IP host is uniquely identified by its IP address.

An IP address consists of a network ID and a host ID.

If two different hosts belong to the same network, they have the same network ID. The two hosts will have different host ID's and can communicate with each other locally without going through a router.

If two hosts have different network ID's, they belong to different segments on the network. They must communicate with each other remotely through a router or default gateway.

An IP address consists of 32 binary bits, where each bit is either a 0 or 1. We first write the 32 bits into four 8-bit numbers separated by a period in between each 8-bit number. 

11000001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

To convert the IP address from binary to decimal form, we convert each of the four 8-bit numbers according to the following table:

8 Bit (octet)

1

1

1

1

1

1

1

1

Decimal (power of 2)

128

64

32

16

8

4

2

1

 

The above IP address would translate into

11000001 = 128 + 64 + 1 = 193

00001010 = 8 + 2 = 10

00011110 = 16 + 8 + 4 + 2 = 30

00000010 = 2

 So in decimal form, the IP address is:

193 . 10 . 30 . 2 

The network ID in the address consists of a certain number of bits starting from the left.

The host ID consists of the remaining bits.

--------------------------------------------------------------------------------------------------------

Example 1. The network ID might consist of the first 8 leftmost bits. Then the host ID consists of the remaining 24 bits.

01010001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

[---8 bits--] [--------------------24 bits-------------------]

[--net ID--] [--------------------host ID-------------------]

01010001 . 10001010 . 00011110 . 00001010 would be an IP address that has the same network ID but a different host ID. The two IP addresses in decimal form are respectively

81.10.30.2 and 81.138.30.10. The two IP addresses are class A addresses because the first eight bits has a decimal value that lies in the range 1 through 126.

The network segment they both belong to is known as 81.0.0.0, where zeros have been substituted in the host ID bits.

---------------------------------------------------------------------------------------------------------

Example 2. The network ID consists of the first 16 leftmost bits and the host ID consists of the next 16 bits.

10000001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

[-----------16 bits ---------] [-----------16 bits----------]

[------------net ID----------] [-----------host ID----------]

10000001 . 00001010 . 00011111 . 00010010 would be an IP address that has the same network ID but a different host ID.

The two IP addresses in decimal form are respectively,

129.10.30.2 and 129.10.31.18 . The two IP addresses are class B addresses because the first eight bits has a decimal value that lies in the range of 128 -191.

The network segment that both IP addresses belong to is named

129.10.0.0, where zeros have been substituted in the host ID bits.

---------------------------------------------------------------------------------------------------------

Example 3. The network ID consists of the first 24 leftmost bits and the host ID consists of the next 8 bits.

11000001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

[-------------------24 bits------------------] [----8 bits---]

[-------------------net ID-------------------] [---host ID--]

11000001 . 00001010 . 00011110 . 00000110 would be an IP address that has the same network ID but a different host ID.

The two IP addresses in decimal form are respectively,

193.10.30.2 and 193.10.30.6. The two IP addresses are class C addresses because the first eight bits has a decimal value that lies in the range of 192-223.

The network segment that both IP addresses belong to is named 193.10.30.0, where zeros have been substituted in the host ID bits.

-----------------------------------------------------------------------------------------

 Default Subnet Masks for Class A, Class B, and Class C addresses

 

How can we identify which bits belong to the network ID and which bits belong to the host ID ?

The answer is to use a subnet mask.

Here is how we write the subnet mask in binary bit form.

If a certain bit is part of the network ID, we write a 1 in the corresponding bit of the subnet mask.

If a certain bit is part of the host ID, we write a 0 in the corresponding bit of the subnet mask.

Going back to examples 1 through 3, we have

------------------------------------------------------------------------------------------------------------- 

Example 1. The network ID might consist of the first 8 leftmost bits. Then the host ID consists of the remaining 24 bits.

01010001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

[---8 bits---] [-------------------24 bits--------------------]

[---net ID--] [-------------------host ID--------------------]

The subnet mask is therefore

[11111111] [00000000 . 00000000 . 00000000] 

Note that the two IP addresses below are on the same network segment because their bits corresponding to a '1' in the subnet mask are identical.

 

01010001 . 00001010 . 00011110 . 00000010 (IP address 81.10.30.2)

 

01010001 . 10001010 . 00011110 . 00001010 (IP address 81.138.30.10)

11111111 . 00000000 . 00000000 . 00000000 (subnet mask 255.0.0.0)

 

For a Class A address, the default subnet mask is 255.0.0.0

---------------------------------------------------------------------------------------------------------

Example 2. The network ID consists of the first 16 leftmost bits and the host ID consists of the next 16 bits.

10000001 . 00001010 . 00011110 . 0000010 (IP address in binary form)

[-----------16 bits----------] [-----------16 bits----------]

[-----------net ID-----------] [-----------host ID----------] 

The subnet mask is therefore

[ 11111111. 11111111] [00000000. 00000000]

Note that the two IP addresses below are on the same network segment because the bits corresponding to a '1' in the subnet mask are identical.

 

10000001 . 00001010 . 00011110 . 00000010 (IP address 129.10.30.2)

 

10000001 . 00001010 . 00011111 . 00010010 (IP address 129.10.31.18)

11111111 . 11111111 . 00000000 . 00000000 (subnet mask 255.255.0.0)

 

For a Class B address, the default subnet mask is 255.255.0.0

---------------------------------------------------------------------------------------------------------

Example 3. The network ID consists of the first 24 leftmost bits and the host ID consists of the next 8 bits.  

11000001 . 00001010 . 00011110 . 00000010 (IP address in binary form)

[------------------24 bits--------------------] [---8 bits---]

[------------------net ID---------------------] [---host ID--]

The subnet mask is therefore

[ 11111111. 11111111. 11111111] [00000000]

 Note that the two IP addresses below are on the same network segment because the bits corresponding to a '1' in the subnet mask are identical.

 

11000001 . 00001010 . 00011110 . 00000010 (IP address 193.10.30.2)

 

11000001 . 00001010 . 00011110 . 00000110 (IP address 193.10.30.6)

11111111 . 11111111 . 11111111 . 00000000 (subnet mask 255.255.255.0)

 

For a Class C address, the default subnet mask is 255.255.255.0

--------------------------------------------------------------------------------------------------------------

 SUBNETTING

Suppose you acquire one single network ID. At this stage, your network can consists of hosts all on one network segment. If you want to set up a network with more than one segment, you must subdivide your network into subnets. The method for subdividing the network is known as subnetting. 

Suppose you have a Class B network of 129.10.0.0.

10000001 . 00001010 . yyyyyyyy . yyyyyyyy (IP address in binary form)

[-----------16 bits----------] [-------16 bits--------]

[-----------net ID-----------] [--------host ID-------]

The first 16 bits form the network ID and the last 16 bits form the host ID. To form different host ID's, we can vary the bits in each of the last 16 bits.

To subdivide this network, we keep the network ID the same. However, we will use some bits from the host ID to form a subnet ID as follows.

[ ----------16 bits---------- ] [ 5 bits ] [ ------11 bits-----]

[ ----------net ID----------- ] [subnet] [ ------host ID-----]

We set the rule that if two hosts are on the same network segment, they must have the same network ID and the same subnet ID. That is, the two hosts must have identical bits in the network ID and subnet ID.

If two hosts have identical network ID's but have different subnet ID's, they are on different subnet segments. Thus, if we can form many different subnet ID's, we have formed many segments in our network.

Before subnetting: one network; different hosts formed from 16 bits

Now: subnet segments formed from 5 bits; different hosts formed from 11 bits

So the rule of thumb is: If we subdivide a network into more subnets, each subnet segment will have fewer potential hosts.

How do we write the subnet mask for the above subnetted network? Recall that if two hosts are on the same segment, their network ID and subnet ID must be identical. In the above subnetted network, there are 16 bits in the network ID and 5 bits in the subnet ID. So we write a '1' for each of these bits in the subnet mask and a '0' for each bit in the host ID 

[ 11111111 11111111] [ 11111] [000 . 00000000] Subnet mask

[ ----------16 bits---------- ] [ 5 bits ] [ -------11 bits ----]

 In decimal form, this subnet mask is 255.255.248.0 (because 11111000 = 248 ; 11111111 = 255)

Given the above subnetted network 129.10.0.0 with subnet mask 255.255.248.0, here are two examples of IP addresses on the same subnet segment.

 

10000001 . 00001010 . 10010 011 . 00010000 (129.10.147.32) IP address 1

 

10000001 . 00001010 . 10010 100 . 01010101 (129.10.148.85)IP address 2

11111111 . 11111111 . 11111 000 . 00000000 (255.255.248.0) subnet mask

 Notice that each '1' in the subnet mask corresponds to a bit that both IP address must have identical.

 10000001 . 00001010 . 10011 011 . 0010000 (129.10.163.32) is an IP address that does not have all bits identical in the bits where there is a '1' in the subnet mask. Therefore, this IP address is on a different subnet segment (remote).

So given two IP addresses and a subnet mask, we can compare the binary bits corresponding to those with a '1' in the subnet mask. If those bits are identical, the two IP addresses belong to the same subnet segment. Otherwise, the two IP addresses belong to two different subnets.

-----------------------------------------------------------------------------------------------

 Calculating Number of Subnets and Hosts in each Subnet

Given a network ID and a subnet mask,

How many subnets can we form?

How many hosts can we form on each subnet?

 The answers to both questions will depend on powers of 2.

Suppose we have the following

[ 16 bits ] [ 3 bits ] [ 13 bits ]

[ network ] [ subnet] [ host ]  

There are three bits used to form the subnet ID. Each bit can have a value of 0 or 1.

Writing all the possibilities for the subnet ID, we have

000 , 001, 010, 011, 100, 101, 110, 111

By rule, we will not accept subnet ID's with all 0's and all 1's.

Therefore, 6 possible subnets can be formed.

Another way to calculate this is to note that in the example, we have three bits and each bit can have two possible values. Therefore, the total possible number of subnets will be (2 x 2 x 2) - 2, where we subtract two to eliminate the all 0's and all 1's cases.

In general, the total number of subnets will be (2 ^ S) - 2, where S is the number of bits in the subnet ID. ( In math symbols,

2 ^ 3 means 2 x 2 x 2 = 8

2 ^ 4 means 2 x 2 x 2 x 2 = 16

2 ^ 5 means 2 x 2 x 2 x 2 x 2 = 32)

We subtract 2 because we rule out both the all 0's and all 1's cases.

In the above example, how many hosts can be formed for each subnet segment?

Since we can form hosts from 13 bits and each bit has two possible values, we can form (2 ^ 13) - 2 hosts. Again, two is subtracted to eliminate the all 0's and all 1's cases.  

In general, the number of hosts per subnet will be

(2 ^ H) - 2 , where H is the number of bits that form the host ID.

 -----------------------------------------------------------------------------------------------

 The Range of Host ID's for a Subnet 

For a given subnet, what are the possible values of host ID's?

Suppose we have the following

[-----------16 bits---------][ 3bits ][-------13 bits-------]

[---------network---------][ subnet][---------host--------]    

Suppose the network ID is 10001111 . 01101011. and the subnet ID is 001. Therefore, an IP address in binary form is

 10000011 . 01101011 . 001 zzzzz . zzzzzzzz (IP address)

11111111 . 11111111 . 111 00000 . 00000000 (subnet mask)

Why should we care how many bits are in the subnet mask? The subnet mask tells us that to generate IP addresses on the same subnet, we vary the bits in the host ID in any manner but keep the bits in the network ID and subnet ID the same.

Varying the bits of the host ID, we find that some of the possible values for IP addresses on this subnet are

10000011 . 01101011 . 001 00000 . 00000000 (131.107. 32. 0)

10000011 . 01101011 . 001 00000 . 00000001 (131.107. 32. 1)

 10000011 . 01101011 . 001 00000 . 00000010 (131.107. 32. 2)

 etc,

 10000011 . 01101011 . 001 00000. 11111110 (131.107. 32.254)

 10000011 . 01101011 . 001 00000. 11111111 (131.107. 32.255)

 10000011 . 01101011 . 001 00001 . 00000000 (131.107. 33. 0)

 10000011 . 01101011 . 001 00001 . 00000001 (131.107. 33. 1)

 etc,

 10000011 . 01101011 . 001 10000 . 00000011 (131.107. 48. 3)

etc.

10000011 . 01101011 . 001 11111 . 11111101 (131.107. 63.253)

10000011 . 01101011 . 001 11111 . 11111110 (131.107. 63.254)

10000011 . 01101011 . 001 11111 . 11111111 (131.107. 63.255)

However, by rule we will not allow all 0's and all 1's in our host ID just as we did not allow all 0's and all 1's in our subnet ID's. We eliminate first and last IP addresses listed above. Therefore, on this subnet, the smallest and largest valid IP addresses are:

10000011 . 01101011 . 001 00000 . 00000001 (smallest, 131.107.32.1)

10000011 . 01101011 . 001 11111 . 11111110 (largest, 131.107.63.254)

In decimal form, we say that the range of possible IP addresses on this subnet is 131.107.32.1 through 131.107. 63.254.

Any other addresses in between these two also belong to the same subnet.

Here is an example of an address that lies on a different subnet.

10000011 . 01101011 . 101 00000 . 00000011 (131.107.160. 3)

11111111 . 11111111 . 111 00000 . 00000000 (subnet mask)

In addition to looking at the bits and subnet mask, we can tell that the above IP address lies on another subnet by the fact that the decimal value of the last two octets is 160.3. Recall that we found previously that for this subnet, the last two octets in the IP address must have a decimal value somewhere between 32.1 and 63.254.

(In decimal numbers,

160.3 is greater than 160

160 is greater than 64

64 is greater than 63.254

Therefore, 160.3 is greater than 63.254)

Next , we present a shortcut for finding the range of IP addresses for a subnet with a given subnet mask.

--------------------------------------------------------------------------------------------

Blocking / Incrementing Shortcut

In the previous example, we had the following situation in decimal form:

Network 131.107. y. z (Class B address)

Subnet mask: 255.255.224. 0

We found previously that the possible range of one of the subnets is:

131.107.32.1 through 131.107.63.254

Shortcut Method

To arrive at that result, we worked with binary bits. Next, we will use a shortcut to arrive at the same answer using only decimal numbers. This shortcut avoids the use of binary numbers.

Step 1: Take the rightmost non-zero number of the subnet mask (224).

Subtract this number from 256. (256 - 224 = 32) This is the increment.

Step 2: Append the increment to your network address.

(131.107. 32. z)

Step 3: Repeatedly add the increment (32) to the result in step 2 until you

reach the original rightmost non-zero number of the subnet mask (224).

131.107. 64.z = 131.107. ( 32 + 32) .z

131.107. 96.z = 131.107. ( 64 + 32) .z

131.107.128.z = 131.107. ( 96 + 32) .z

131.107.160.z = 131.107. (128 + 32) .z

131.107.192.z = 131.107. (160 + 32) .z

131.107.224.z but we do not accept this one because 224 corresponds to the case of a subnet ID with all 1's. (224 = 11100000)

Step 4: Write out the smallest and largest IP addresses for your subnets.

For our first subnet, we have 131.107.32.z. The smallest possible value is 131.107.32.1 because our host ID cannot have all 0's. The largest value on this subnet must be smaller than the start of the next subnet, which is 131.107.64.1. In addition, our host ID cannot have all 1's. So we eliminate 131.107.63.255 as a valid IP address. The largest value for an IP address on this subnet would be 131.107.63.254.**

** Note:

11111111 . 11111111 . 11100000 . 00000000 (subnet mask 255.255.224.0)

10000011 . 01101011 . 001 11111 . 11111110 (131.107.63.254,accepted)

 10000011 . 01101011 . 001 11111 . 11111111 (131.107.63.255, largest binary value but not accepted because of all 1's in host ID)

 10000011 . 01101011 . 010 00000 . 00000001 (131.107.64.1, smallest value for next subnet)

 Using the above logic, we find these to be range of values for all 6 subnets:

Subnet 1: 131.107. 32. 1 through 131.107. 63.254

Subnet 2: 131.107. 64. 1 through 131.107. 95.254

Subnet 3: 131.107. 96. 1 through 131.107.127.254

Subnet 4: 131.107. 128.1 through 131.107.159.254

Subnet 5: 131.107. 160.1 through 131.107.191.254

Subnet 6: 131.107. 192.1 through 131.107.223.254

 -----------------------------------------------------------------------------------------------

Example 2 (Class A IP addresses) 

Network : 10. X. y. z

Subnet Mask 255.240.0.0

 What are the ranges of IP addresses for all subnets?

240 is the rightmost nonzero number in the subnet mask.

256 - 240 = 16 (increment)

Append the increment to the network address until you reach 240.

10. 16.0.z

10. 32.0.z = 10. ( 16 + 16) .0 .z

10. 48.0.z = 10. ( 32 + 16) .0 .z

10. 64.0.z = 10. ( 48 + 16) .0 .z

10. 80.0.z and so on

10. 96.0.z

10.112.0.z

10.128.0.z

10.144.0.z

10.160.0.z

10.176.0.z

10.192.0.z

10.208.0.z

10.224.0.z

10.240.0.z but we do not accept this one because this corresponds to all 1's in the subnet ID.

 Subnet 1: 10. 16. 0. 1 through 10.31.255.254 **

Subnet 2: 10. 32. 0. 1 through 10.47.255.254

Subnet 3: 10. 48. 0. 1 through 10.63.255.254

Subnet 4: 10. 64. 0. 1 through 10.79.255.254

and so forth

 ** Note:

11111111 . 11110000 . 00000000 . 00000000 (subnet mask 255.240.0.0)

00001010 . 00011111 . 11111111 . 11111110 (10.31.255.254)

is the largest possible acceptable IP address on the same subnet that is less than:

 00001010 . 00100000 . 00000000 . 00000001 (10.32. 0. 1)

  --------------------------------------------------------------------------------------------------

 Creating Your TCP/IP Chart

 To get your answers quickly during the exam, you should use a chart that you've written down during the astronomy tutorial.

 

A   1    - 126, N = 8 bits

B  128 - 191, N = 16 bits

C  192 - 223, N = 24 bits, where N = how many bits in Network ID

N + S + H = 32, where S = # of bits in Subnet ID, H = # of bits in Host ID

 

# bits

subnet

# subnets

increment

 # hosts  =(2^H) - 2

in mask (S)

mask

 (2^S) - 2

256 - mask

A

B

C

2

192

2

64

4M

16K

62

3

224

6

32

2M

8K

30

4

240

14

16

1M

4K

14

5

248

30

8

500K

2K

6

6

252

62

4

250K

1K

2

7

254

126

2

130K

510

----

8

255

254

1

65K

254

----

 

 

You only need to remember a few things to derive the whole chart.

The second column is the sum of 128 + 64, 

                                                 128 + 64 + 32

                                                 128 + 64 + 32 + 16, and so on

The third column is (2^S) - 2, starting with S = 2

The other columns can be derived through dividing by 2.  

The last column is a reverse of the third column, starting with 62.