You are on page 1of 10

IP Addressing Notes

(Revised 6-2-2011)

Example 1
The (sub)network address is 192.168.144.0 /28.
1. What is the subnet mask?
The subnet mask starts with 28 1s and ends with 4 0s because the total length is 32 bits:
11111111111111111111111111110000
Add the dots to separate the octets. Convert each octet to decimal to put this in dotted decimal notation.
11111111.11111111.11111111.11110000

255.255.255.240

2. How many IP addresses are in this network, including the network address and the broadcast address?
Write down the network ID in binary:
192.168.144.0

11000000.10101000.10010000.0000 0000

The network ID (in blue) is 28 bits long. The host ID (in red) is 4 bits long. All IP addresses in this network must start
with the same 28 bits, since they all have the same nework ID. An IP address on this network must look like this:
11000000.10101000.10010000.0000 _ _ _ _
There are two ways to fill out each host ID bit _ . Therefore there are 24=16 IP addresses in this network.
3. What is the broadcast address of this network?
In a (directed) broadcast address, all host ID bits are 1s:
192.168.144.15 11000000.10101000.10010000.0000 1111
4. What is the range of IP addresses that can be assigned to computers and other hosts?

192.168.144.0
192.168.144.1
192.168.144.2
192.168.144.3
192.168.144.4
192.168.144.5
192.168.144.6
192.168.144.7
192.168.144.8
192.168.144.9
192.168.144.10
192.168.144.11
192.168.144.12
192.168.144.13
192.168.144.14
192.168.144.15

11000000.10101000.10010000.0000 0000
11000000.10101000.10010000.0000 0001
11000000.10101000.10010000.0000 0010
11000000.10101000.10010000.0000 0011
11000000.10101000.10010000.0000 0100
11000000.10101000.10010000.0000 0101
11000000.10101000.10010000.0000 0110
11000000.10101000.10010000.0000 0111
11000000.10101000.10010000.0000 1000
11000000.10101000.10010000.0000 1001
11000000.10101000.10010000.0000 1010
11000000.10101000.10010000.0000 1011
11000000.10101000.10010000.0000 1100
11000000.10101000.10010000.0000 1101
11000000.10101000.10010000.0000 1110
11000000.10101000.10010000.0000 1111

Network Address 192.168.144.0 /28


First host address in this (sub)network
2nd host address in this (sub)network
3rd host address in this (sub)network

14th host address in this (sub)network


Directed broadcast address

Exercise 1
The (sub)network address is 192.168.1.160 /27.
1. What is the subnet mask?
255.255.255.224
2. How many IP addresses are in this network, including the network address and the broadcast address?
32
3. What is the broadcast address of this network?
192.168.1.191

192.168.1.160

11000000.10101000.00000001.101 00000

192.168.1.191

11000000.10101000.00000001.101 11111

4. What is the range of IP addresses that can be assigned to computers and other hosts?
192.168.1.161 - 192.168.1.190

Example 2
The address of a computer is 172.16.213.20. Its subnet mask is 255.255.252.0
1. What is the prefix length, i.e., how many bits long is the network ID?
Write down the subnet mask in binary. This will show us the prefix length:
255.255.252.0

11111111.11111111.11111100.00000000

It starts with 22 1s. Therefore the prefix length is 22. It is the length of our network ID.
2. How many bits does the host ID have? How many IP addresses are on this network?
An IP address has 32 bits. If the network ID is 22 bits long, then there are 32 - 22 = 10 host ID bits. This network will
have 210 = 1024 IP addresses, including the network address and the broadcast address. Why 210? An IP address
on this network will have this form:
NNNNNNNN.NNNNNNNN.NNNNNN HH.HHHHHHHH
Each host address bit H can be either 0 or 1. Since there are 10 host bits H, there are 210 possible combinations of
0s and 1s.
3. What is the network address of the network that has this computer?
Write down the computer's IP address in binary:

10101100.00010000.110101 01.00010100

172.16.213.20

The 22 network ID bits are in blue and the 10 host ID bits are in red. In a (sub)network address, all host bits are 0s.
So we can just replace all the host ID bits with 0s. Alternatively, we can use the bitwise AND operation. This is
actually how computers extract the network ID from the host ID and subnet mask:
10101100.00010000.110101 01.00010100
172.16.213.20 IP address
11111111.11111111.111111 00.00000000
255.255.252.0 Subnet mask
AND
________________________________________________________________________
10101100.00010000.110101 00.00000000
172.16.212.0
(sub)network address
The host 172.16.213.20, therefore, belongs in the network with address 172.16.212.0 /22.
4. What is the broadcast address of this network?
In a broadcast address, all the host bits are 1s:
10101100.00010000.110101 00.00000000
10101100.00010000.110101 11.11111111

172.16.212.0
(sub)network address
172.16.215.255 broadcast address

5. What is the range of IP addresses that can be assigned to computers and other hosts?
All hosts in network 172.16.212.0 /22 must have the same network ID. So their IP addresses have this form:
10101100.00010000.110101 _ _._ _ _ _ _ _ _ _

172.16.212.0

(sub)network address

We list the first few and last few host addresses in this network:
10101100.00010000.110101 00.00000000
10101100.00010000.110101 00.00000001
10101100.00010000.110101 00.00000010
10101100.00010000.110101 00.00000011
...
10101100.00010000.110101 00.11111110
10101100.00010000.110101 00.11111111
10101100.00010000.110101 01.00000001

172.16.212.0
172.16.212.1
172.16.212.2
172.16.212.3

(sub)network address
first host address
2nd host address
3rd host address

172.16.212.254
172.16.212.255
172.16.213.0

254th host address


255th host address
256th host address

...
10101100.00010000.110101 11.11111110
10101100.00010000.110101 11.11111111

172.16.215.254
172.16.215.255

1022nd host address


broadcast address

Example 3
Divide the network 192.168.1.0 /24 into exactly 8 subnetworks (subnets).
1. How many bits do we borrow?
Number of subnets = 2number of bits borrowed. So if we borrow 3 bits, we create exactly 23 = 8 subnets.
The number of bits borrowed is the number of original host ID bits that will become network ID bits.
2. How many IP addresses are in each subnet?
Number of IP addresses per subnet = 2number of host ID bits left. In a class C network (/24--N.N.N.H), there originally 8
host ID bits. Since we borrowed 3 bits, 8 - 3 = 5 host ID bits left. Therefore there are 25 = 32 IP addresses per
subnet, including the (sub)network address and the broadcast address.
Alternatively, (256 IP addresses in a /24 network) / (8 subnets) = 32 IP addresses per subnet.
3. What is the new subnet mask and prefix length.
11111111.11111111.11111111.00000000
255.255.255.0
Original (default) subnet mask
11111111.11111111.11111111.11100000
255.255.255.224
New subnet mask after borrowing 3 bits.
The original prefix length is 24. The new prefix length is 24 + 3 = 27.
3. List the addresses of each of the eight subnets.
11000000.10101000.00000001.000 00000
11000000.10101000.00000001.001 00000
11000000.10101000.00000001.010 00000
11000000.10101000.00000001.011 00000
11000000.10101000.00000001.100 00000
11000000.10101000.00000001.101 00000
11000000.10101000.00000001.110 00000
11000000.10101000.00000001.111 00000
The borrowed bits are in blue.

192.168.1.0
192.168.1.32
192.168.1.64
192.168.1.96
192.168.1.128
192.168.1.160
192.168.1.192
192.168.1.224

Subnet 0
Subnet 1
Subnet 2
Subnet 3
Subnet 4
Subnet 5
Subnet 6
Subnet 7 All ones subnet.

4. List the first few and last few addresses in subnet 3.


11000000.10101000.00000001.011 00000
11000000.10101000.00000001.011 00001
11000000.10101000.00000001.011 00010
...
11000000.10101000.00000001.011 11110
11000000.10101000.00000001.011 11111

192.168.1.96
192.168.1.97
192.168.1.98

Subnet 3
First host address in subnet 3
Second host address in subnet 3

192.168.1.126
192.168.1.127

30th host address in subnet 3


Broadcast address of subnet 3

Example 3 Class B
Divide the network 172.16.0.0 into at least 50 subnets. Each subnet must accommodate at least 800 computers.
1. How many bits do we borrow? How many subnets did you create? How many IP addresses are in each subnet?
Number of subnets = 2number of bits borrowed.
If we borrow 5 bits, we create exactly 25 = 32 subnets. Not enough subnets.
If we borrow 6 bits, we create exactly 26 = 64 subnets
If we borrow 7 bits, we create exactly 27 = 128 subnets
The number of bits borrowed is the number of original host ID bits that will become network ID bits.
Number of IP addresses per subnet = 2number of host ID bits left. In a class B network (/24--N.N.H.H), there originally 16
host ID bits.
If we borrow 6 bits, 16 - 6 = 10 host ID bits remain. Therefore there will be 210 = 1024 IP addresses per
subnet, including the (sub)network address and the broadcast address. This works.
If we borrow 7 bits, 16 - 7 = 9 host ID bits remain. Therefore there will be 29 = 512 IP addresses per subnet,
including the (sub)network address and the broadcast address. The subnets will not be large enough to
accommodate 800 computers.
Therefore we must borrow exactly 6 bits.
2. What is the new subnet mask and prefix length?
Original /16 subnet mask:

11111111.11111111.00000000.00000000
6

255.255.0.0

New /22 subnet mask:


11111111.11111111.11111100.00000000
The position of the 6 borrowed bits is in blue.

255.255.252.0

3. List the first few and last few subnet addresses?


10101100.00010000.000000 00.00000000
10101100.00010000.000001 00.00000000
10101100.00010000.000010 00.00000000
...
10101100.00010000.111110 00.00000000
10101100.00010000.111111 00.00000000

172.16.0.0
172.16.4.0
172.16.8.0

Subnet 0
Subnet 1
Subnet 2

172.16.248.0
172.16.252.0

Subnet 62
Subnet 63 "All ones" subnet

In a subnet address all host ID bits are 0. In this case, the last 10 bits are the host ID bits. These addresses cannot
be assigned to computers and other hosts.
4. What is the range of IP addresses in subnet 49?
10101100.00010000.110001 00.00000000
10101100.00010000.110001 00.00000001
10101100.00010000.110001 00.00000010
10101100.00010000.110001 00.00000011
...
10101100.00010000.110001 00.11111110
10101100.00010000.110001 00.11111111
10101100.00010000.110001 01.00000000
10101100.00010000.110001 01.00000001
...
10101100.00010000.110001 11.11111110
10101100.00010000.110001 11.11111111

172.16.196.0
172.16.196.1
172.16.196.2
172.16.196.3

Subnet 49 (sub)network address


First host on subnet 49
Second host on subnet 49
Third host on subnet 49

172.16.196.254
172.16.196.255
172.16.197.0
172.16.197.1

254th host on subnet 49


255th host on subnet 49
256th host on subnet 49
257th host on subnet 49

172.16.199.254
172.16.199.255

1022nd host on subnet 49


Directed broadcast address of subnet 49

Example 4 Class B
Divide the network 172.16.0.0 into at least 800 subnets. Each subnet must accommodate at least 50 computers.
1. How many bits do we borrow? How many subnets did you create? How many IP addresses are in each subnet?
Number of subnets = 2number of bits borrowed.
If we borrow 9 bits, we create exactly 29 = 512 subnets. Not enough subnets.
If we borrow 10 bits, we create exactly 210 = 1024 subnets
If we borrow 11 bits, we create exactly 211 = 2048 subnets
The number of bits borrowed is the number of original host ID bits that will become network ID bits.
Number of IP addresses per subnet = 2number of host ID bits left. In a class B network (/24--N.N.H.H), there originally 16
host ID bits.
If we borrow 10 bits, 16 - 10 = 6 host ID bits remain. Therefore there will be 26 = 64 IP addresses per subnet,
including the (sub)network address and the broadcast address. This works.
If we borrow 11 bits, 16 - 11 = 5 host ID bits remain. Therefore there will be 25 =32 IP addresses per subnet,
including the (sub)network address and the broadcast address. The subnets will not be large enough to
accommodate 800 computers.
Therefore we must borrow exactly 10 bits.
2. What is the new subnet mask and prefix length?
Original /16 subnet mask:
11111111.11111111.00000000.00000000
New /26 subnet mask:
11111111.11111111.11111100.00000000
The position of the 10 borrowed bits is in blue.

255.255.0.0
255.255.255.192

3. List the first few and last few subnet addresses?


10101100.00010000.00000000.00 000000
10101100.00010000.00000000.01 000000
10101100.00010000.00000000.10 000000
10101100.00010000.00000000.11 000000

172.16.0.0
172.16.0.64
172.16.0.128
172.16.0.192
8

Subnet 0
Subnet 1
Subnet 2
Subnet 3

10101100.00010000.00000001.00 000000
10101100.00010000.00000001.01 000000
10101100.00010000.00000001.10 000000
10101100.00010000.00000001.11 000000
...
10101100.00010000.11111111.00 000000
10101100.00010000.11111111.01 000000
10101100.00010000.11111111.10 000000
10101100.00010000.11111111.11 000000
In a subnet address, all host bits are 0.

172.16.1.0
172.16.1.64
172.16.1.128
172.16.1.192

Subnet 4
Subnet 5
Subnet 6
Subnet 7

172.16.255.0
172.16.255.64
172.16.255.128
172.16.255.192

Subnet 1020
Subnet 1021
Subnet 1022
Subnet 1023 "All ones" subnet

4. What is the range of IP addresses in subnet 799?


10101100.00010000.11000111.11 000000
172.16.199.192
10101100.00010000.11000111.11 000001
172.16.199.193
10101100.00010000.11000111.11 000010
172.16.199.194
...
10101100.00010000.11000111.11 111110
172.16.199.254
10101100.00010000.11000111.11 111111
172.16.199.255

Subnet 799
First host address in subnet 799
Second host address in subnet 799
62nd host on subnet 799
Directed broadcast address of subnet 799

Lab 6.7.3 Challenge #6


192.168.3.219
11000000.10101000.00000011.110 11011
IP address
255.255.255.224
11111111.11111111.11111111.111 00000
/27 subnet mask
AND
-----------------------------------------------------------------------------------------------------------------------------------------192.168.3.192
11000000.10101000.00000011.110 00000
Subnet 6 address
192.168.3.223
11000000.10101000.00000011.110 11111
Broadcast address of subnet 6
192.168.3.192 - 192.168.3.223 is a range of 32 IP addresses. 30 can be assigned to computers and other hosts.

Lab 6.7.4 Problem #1


9

172.30.1.33
10101100.00011110.00000001.00100001
IP address
255.255.255.0
11111111.11111111.11111111.00000000
/24 subnet mask
-----------------------------------------------------------------------------------------------------------------------------------------172.30.1.0
10101100.00001110.00000001.00000000
Subnet 1
172.30.1.255
10101100.00001110.00000001.11111111
Broadcast address for subnet 1

10

You might also like