IP ADDRESSING TUTORIAL
Devices on networks have addresses: Internet Protocol (IP) version
4 addresses are expressed in dotted decimal and binary numbers,
whilst Media Access Control (MAC) addresses and IP version 6
addresses are expressed in hexadecimal.
Part 1: IP Addresses Recap
Recall the structure of an IPv4 address:
- 32 bits
- written in dotted decimal: divide 32 bits into 4 octets (groups
of 8 bits), each octet is converted into a decimal number
between 0 and 255; octets separated by a dot .
- accompanied by a subnet mask in dotted decimal, prefix
length (slash notation) or binary
On the other hand, an IPv6 address:
- 128 bits
- also written in hexadecimal: divided into eight hextets (16 bits),
each hextet is converted into four hex digits; hextets separated
by :
- accompanied by a subnet mask as prefix length
Each IP address has two parts: the network portion(prefix) and the
host portion. The subnet mask identifies which bits are the network
bits and which are the host bits. All devices in the same network will
have the same network portion, and the same subnet mask. Subnet
masks can be represented in binary, in dotted decimal (for IPv4 ) or
in prefix notation (slash notation), specifying the number of network
bits. Without its associated subnet mask, an IP Address is simply a set
IP Addressing Tutorial Page 1
of numbers. There is a direct relationship bit-for-bit between the IP
address and the subnet mask.
If a subnet mask bit is a one, the corresponding IP address bit
belongs to the network portion of the address.
If a subnet mask bit is a zero, the corresponding IP address bit
belongs to the host portion of the address.
Part 2: Types of IPv4 addresses
Given an IP address and a subnet mask, we can find:
- The network (first) address the IP address belongs to
- The range of addresses that belong to the same network (host
or useable addresses)
- The broadcast (last) address for the network
To find the network address
1. Convert the IPv4 address to binary
2. Convert the subnet mask to binary
3. Line the IP address and the subnet mask bit for bit
4. Apply the binary AND operation
The result is the network address – all host bits should be 0.
Example: Address 167.199.170.82/27
IP Address in binary 10100111 11000111 10101010 01010010
AND
Mask in binary 11111111 11111111 11111111 11100000
-----------------------------------------------------------------------------------
Network address 10100111 11000111 10101010 01000000
167.199.170.64 in dotted decimal
IP Addressing Tutorial Page 2
The network address identifies the network that the address belongs
to. It has all 0’s in the host portion. This address is used by routers to
route a packet to its destination network.
This address should not be allocated to devices.
The broadcast address
Every network has a broadcast address. This is a special address used
as the destination address of a packet if the device wants to send the
packet to all devices in the same network. All devices in the network
will receive the packet and process it. It is also the last address in the
network. This address has all 1’s in the host portion. Therefore, to find
the broadcast address, keep the network bits intact, change all host
bits to 1. Like the network address, this address should not be
allocated to devices.
Using the example above, the broadcast address for the network will
be
10100111 1100011 10101010 01011111
167.199.170.95 in dotted decimal
Useable Host addresses
These are the addresses that are in the same network. They are called
useable because they can be allocated to devices in the network. All
addresses between the network address and the broadcast address
are useable addresses. These addresses have a combination of 0’s and
1’s in the host portion. There is a total of 2n - 2 useable addresses in
a network, where n is the number of host bits.
To find the total number of addresses in a network, the formula is
2n , where n is the number of host bits. The network address and the
IP Addressing Tutorial Page 3
broadcast address can’t, and should not, be allocated to devices,
therefore have to be subtracted to get the useable hosts.
Using our example, the address has 5 host bits
This means that there are 2 5 - 2= 30 useable addresses in the
network
These addresses range from 167.199.170.64 to 167.199.170.94
inclusive.
The first useable address is the network address +1. This can be
achieved by adding 1 to the last octet using the network address. This
address has all 0 on the host portion, except the last bit.
For our example, the first useable address is 167.199.170.65. The last
octet of the network address has 64, so 64+1 = 65.
The last useable address is the broadcast address – 1. Subtract 1 from
the last octet using the broadcast address. This address has all 1’s in
the host portion, except the last bit.
The last useable address for our example is therefore 167.199.170.94.
Question 1
a) How many bits are in an IPv4 address? _______________________
b) How many bits does an IPv6 address have? ____________________
c) How large is an IPv4 address space in total? ____________________
d) How large is an IPv6 address space in total? ____________________
IP Addressing Tutorial Page 4
e) How is an IPv4 represented?
f) How is an IPv6 represented?
Question 2
Convert the following subnet masks into prefix length (slash notation)
a) 255.255.255.252
b) 255.255.0.0
Question 3
Convert the following prefixes into dotted decimal subnet masks. Hint:
First convert into binary notation, then into dotted decimal
a) /15
b) /22
IP Addressing Tutorial Page 5
Question 4
Given the following address, find the network address, the first useable
address, the last useable address, host addresses range and the
broadcast address Show all calculations.
a) 172.16.29.104/16
b) 192.168.3.55/23
c) 201.37.16.19/28
Question 1
What is wrong with the following IP addresses?
a. 1.2.3
b. 1.2.3.4.
c. 1.2.3.4.5
d. 1.255.255.2556
Question 5
Given address 201.37.16.19/19
a. Calculate the number of host bits.
b. Calculate the total number of hosts in the network.
c. Calculate the number of useable hosts in the network.
d. Find the network address in dotted decimal. Show your working.
IP Addressing Tutorial Page 6
e. What is the broadcast address of the network in dotted decimal?
f. What is the tenth useable address in the network?
g. Another device has an IP address 201.38.16.19/19. Is the device
in the same network? Show all your work.
IP Addressing Tutorial Page 7