www.cisconetsolutions.
com
IPv4 Addressing and Subnetting
It is important to understand how to convert from IPv4 decimal notation to binary for subnetting
and summarization.
The binary system is based on ones (1) and zeros (0).
There are 8 bits per octet, 4 octets per IPv4 address.
The bit value is based on position.
The bit set to 1 sets the value. The bit set to zero = 0
There are 8 bits with 2 (nth power) so 28 = 255
Per octet: set all bits to 1 = 255, set all bits to 0 = 0
0 0 0 0 0 0 0 0 =0
1 1 1 1 1 1 1 1 = 255
128 64 32 16 8 4 2 1 bit value
8 7 6 5 4 3 2 1 bit position
Binary to Decimal Conversion
Converting binary number to an equivalent decimal number requires adding the values of each
bit position set to (1) for each octet. The sum of each octet creates a dotted decimal address.
0 0 0 0 1 0 1 0 = 10
from right to left, 2nd bit = 2 and 4th bit = 8 = 2+8 = 10
Binary to Decimal Conversion
Converting the binary number to an equivalent decimal number requires adding the values of
each bit position set to (1) for each octet. The sum of each octet creates a dotted decimal value
(IP address).
00001010.01100100.00101000.10000000
(8+2) . (64+32+4) . (32+8) . 128 = 10.100.40.128
Decimal to Binary Conversion
Converting IPv4 address 192.168.64.10 to an equivalent binary number requires setting specific
bits for each octet to (1) value. The sum of each octet adds up to decimal value for each octet.
192 . 168 . 64 . 10
11000000 . 10101000 . 01000000 . 00001010
(128+64) . (128+32+8) . 64 . (8+2)
www.cisconetsolutions.com
Hexadecimal to Binary Conversion
IPv6 addressing is based on hexadecimal format instead of IPv4 octets. The IPv6 address is
comprised of 32 hexadecimal values of 4 bits each. The IPv6 address is as a result 128 bits in
length (4 bits x 32 hexadecimal values). Each hexadecimal number has 16 possible values that
range from 0 to F derived from the lower 4 bits of an octet. The same values from 0-9 are used
for IPv4 and IPv6 binary to decimal conversion. The values 10 to 15 however are A to F.
Hexadecimal D = 1 1 0 1
8 4 0 1 = 8 + 4 + 1 = 13 decimal
Hexadecimal F = 1 1 1 1
8 4 2 1 = 8 + 4 + 2 + 1 = 15 decimal
A = 10 (1010) B = 11 (1011) C = 12 (1100)
D = 13 (1101) E = 14 (1110) F = 15 (1111)
Converting FDA4 to binary = 1111 1101 1010 0100
F D A 4
IPv4 Address Classes
The following are the assignable classes for IPv4 address space. The address range from
127.0.0.0 – 127.255.255.255 is reserved for host-based loopback address.
Class A = 255.0.0.0 (0.0.0.0 - 127.255.255.255)
Class B = 255.255.0.0 (128.0.0.0 - 191.255.255.255)
Class C = 255.255.255.0 (192.0.0.0 - 223.255.255.255)
Class D = 224.0.0.0 - 239.255.255.255 (multicast)
Class E = 240.0.0.0 - 255.255.255.255 (reserved)
RFC 1918 Private IPv4 Addressing
RFC 1918 defines private IP address space from each address class. The private IP addressing
is not public routable across the internet. The standard practice is for companies to assign
private addressing to all inside hosts. NAT is deployed at the internet edge where private
addresses are translated to public routable addresses.
The following are the RFC 1918 private IP address ranges:
10.0.0.0 - 10.255.255.255 /8
172.16.0.0 - 172.31.255.255 /12
192.168.0.0 - 192.168.255.255 /16
www.cisconetsolutions.com
Classful Subnet Mask
Classful subnet masks are based on the default mask length for each IP class. That includes
Class A = /8, Class B = /16 and Class C = /24. Any routing protocol that only supports classful
subnet masks must use the default for the address class deployed. The default subnet mask
implies subnetting is not configured for an address class.
Class A = 255.0.0.0 (/8)
Class B = 255.255.0.0 (/16)
Class C = 255.255.255.0 (/24)
Classless Subnet Mask
Classless subnet masks are referred to as variable length subnet mask (VLSM). They are any
subnet mask that is not the default for a particular address class. They enable more specific
routes to a destination. In addition subnetting is enabled to optimize available address space.
The network portion of an IP address is shifted to the right or left. That changes the subnet
mask length and enable subnetting. The number of subnets and host assignments available is
based on the subnet mask length.
Classless vs Classful Subnet Masks
255.0.0.0 = classful (default class A subnet mask)
255.255.224.0 = classless
255.255.255.248 = classless
255.255.0.0 = classful (default class B subnet mask)
255.255.255.0 = classful (default class C subnet mask)
Table 1 Class C Subnetting Table
Subnet Mask CIDR Subnet Bits Subnets Host Bits * Hosts
255.255.255.0 /24 0 1 8 254
255.255.255.128 /25 1 2 7 126
255.255.255.192 /26 2 4 6 62
255.255.255.224 /27 3 8 5 30
255.255.255.240 /28 4 16 4 14
255.255.255.248 /29 5 32 3 6
255.255.255.252 /30 6 64 2 2
255.255.255.254 /31 not recommended 2
255.255.255.255 /32 - - - 1
* The host number does not include the network address and broadcast address. They are
reserved for each individual subnet and are not assignable to any hosts. For example
8 host bits = 28 = 256 - 2 = 254
www.cisconetsolutions.com
Subnetting Example 1:
What network address would allow the maximum number of subnets for 172.16.1.0/23 with 30
hosts? The subnet mask defines the network portion (bold) and host portion of an IP address.
The subnet mask /23 (255.255.254.0) assigns 23 bits to the network portion and 9 bits to host
portion. The number of assignable hosts is 29 = 512 - 2.
network | host
172.16.1.0 = 10101100.00010000.0000000 1.00000000
255.255.254.0 = 11111111.11111111.1111111 0.00000000
network | host
255.255.255.224 = 11111111.11111111.11111111.111 00000
The question asked for a maximum of 30 hosts. The subnet mask is used to modify the network
portion and consequently the host portion as well. Moving the subnet mask to the right will
increase the network portion and decrease the host portion assignable. Assigning the rightmost
5 bits provides a maximum of 30 hosts from the subnetting table (32 - 2). The network address
and broadcast address cannot be assigned to hosts.
The host portion must be decreased from 9 bits to 5 bits. That will require increasing the subnet
mask from /23 to /27.
subnet with 30 hosts = 172.16.1.0/27
Subnetting Example 2:
What IP address is assignable to a host based on subnet mask 255.255.255.224?
A. 192.168.10.31
B. 192.168.10.29
C. 192.168.10.0
D. 192.168.10.32
The network address and broadcast address are not assignable to hosts. The subnet multiple is
calculated based on the bit value of bit position 6. Subnet multiples start at 0 with multiples of 32
(0, 32, 64, 96, 128, 160, 192, 224).
network | host
11111111.11111111.11111111.111 00000
255. 255. 255. 224
1. 4th octet is subnetted
2. subnet multiple = bit position 6 = decimal 32
3. network address of zero subnet = 192.168.10.0
4. host range = first 5 bits = 25 = 32 - 2 = 30 host assignments
www.cisconetsolutions.com
network address = 192.168.10.0
host range = 192.168.10.1 - 192.168.10.30
broadcast address = 192.168.10.31
Subnetting Example 3:
Select the correct network address and subnet mask that allows at least ten web servers (hosts)
to be assigned to the same subnet?
A. 192.168.100.0 255.255.255.252
B. 192.168.100.16 255.255.255.248
C. 192.168.100.16 255.255.255.240
D. 192.168.252.16 255.255.255.252
The subnet mask defines the network portion and host portion of a subnetted address.
Increasing the subnet mask length will increase the number of subnets available. Creating 10
host assignments for web servers requires at least 4 host bits. That allows for 14 host
assignments where network and broadcast addresses are not assignable.
23 = 3 host bits = 8 - 2 = 6 host assignments
24 = 4 host bits = 16 - 2 = 14 host assignments
network portion = 32 bits - 4 bits = 28 bits (/28)
= 255.255.255.240
network (28 bits) | host (4 bits)
11111111.11111111.11111111.1111 0000
255. 255. 255. 240
The 255.255.255.240 (/28) subnet mask starts at the bit 5 of the 4th octet and has a decimal
value of 16. The subnets are multiples of 16 (0, 16, 32, 48 etc).
Correct Answer: 192.168.100.16/28
Subnetting Example 4:
What is the second IP address available for host assignment from 172.33.1.64/30?
A. 172.33.1.64
B. 172.33.1.65
C. 172.33.1.66
D. 172.33.1.1
www.cisconetsolutions.com
The IP address is a nondefault Class A address. The subnet mask defines the number of bits
assigned to the network portion and host portion. The /30 subnet mask creates a network
portion of 30 bits and a host portion of 2 bits. The number of host assignments available with 2
bits = 22 = 4. The network address and broadcast address are not assignable to hosts. As a
result the number of host assignments = 4 - 2 = 2 IP addresses. The following is a list of all IP
addresses for subnet 172.33.1.64/30.
network (subnet) address = 172.33.1.64
first assignable host IP address = 172.33.1.65
second assignable host IP address = 172.33.1.66
broadcast address = 172.33.1.67
network | host
172.33.1.64 = 10101100.00100001.00000001.010000 00
255.255.255.252 = 11111111.11111111.11111111.111111 00
The rightmost bit of the subnet mask (network bits) determines the subnet multiple and where it
starts. For this example, bit 3 of the 4th octet has a decimal value of 4. The subnet multiple
starts at 0 with multiples of 4 (0, 4, 8, 12 etc). The next subnet available is 172.33.1.68/30.
Interfaces on the same router must be assigned to different subnets.
Wildcard Masks
The wildcard mask is a technique to match an IP address or range of IP addresses. It is used by
routing protocols and access control lists (ACL) to manage routing and packet filtering. The
wildcard mask is an inverted mask where the matching IP address or range is based on 0 bits.
The additional bits are set to 1 as no match required. The wildcard 0.0.0.0 is used to match a
single IP address. Wildcard mask for 255.255.224.0 is 0.0.31.255 (invert the bits so zero=1 and
one=0)
11111111.11111111.111 00000.00000000 = subnet mask
00000000.00000000.000 11111.11111111 = wildcard mask
Example 1: Classful Wildcard Mask
The following wildcard will only match on the 192.168.3.0 subnet and not match on everything
else. This could be used with an ACL for instance to permit or deny a subnet. It could define a
single subnet to advertise from OSPF as well.
192. 168. 3. 0
11000000.10101000.00000011.00000000
00000000.00000000.00000000.11111111 = 0.0.0.255
www.cisconetsolutions.com
Example 2: Classless Wildcard Mask
The classless wildcard can filter based on any network boundary. The following wildcard mask
matches on the subnet 192.168.4.0 serial link only. It is the equivalent of 255.255.255.252
subnet mask.
192. 168. 4. 0
11000000.10101000.00000100.00000000
00000000.00000000.00000000.00000011 = 0.0.0.3
192.168.4.0 0.0.0.3 = match on 192.168.4.1 and 192.168.4.2
The CIDR notation denotes the number of bits in the subnet mask. For instance a class C
address with subnet mask 255.255.255.240 = /28