3 - IPv4 – Addressing and Subnetting
3 - IPv4 – Addressing and Subnetting
3 - IPv4 – Addressing and Subnetting
Binary Numbering
● It defines the first 64 bits as the network address and the last 64 bits
as the host address.
IPv4 Address Classes
● IP addresses are grouped into classes.
● Each class has a range of IP addresses.
● The range of IP addresses in each class is determined by the number
of bits allocated to the network section of the 32-bit IP address.
Class Range Subnet Mask
A 128 16,777,214
B 16,384 65534
C 2,097,152 254
IPv4 Address Classes
The total number of available hosts on a network can be determined from it's
subnet mask
The total number of networks a class address may have is calculated by subtracting the
number of bits in the subnet mask from the number of bits used to determine which class
of network it is.
Special Use IPv4 Addresses
Loopback Addresses
● 127.0.0.0 /8 (127.0.0.1 to 127.255.255.255.254)
● Commonly identified as only 127.0.0.1
● Used on a host to test if TCP/IP is operational.
Link-Local Addresses
● 169.254.0.0 /16 (169.254.0.1 to 169.254.255.255)
● Commonly known as the Automatic Private IP Addressing (APIPA)
addresses or self-assigned addresses.
● Used by Windows DHCP clients to self-configure when no DHCP
servers are available
Private and Public IPv4
Private IP Public IP
Cannot be used on the internet To send or receive traffic
because private addresses are not on the internet
globally routable.
They are common blocks of Normally assigned by
addresses used by most your ISP
organizations to assign IPv4
addresses to internal hosts.
Range: Range: Besides private IP
10.0.0.0 – 10.255.255.255, addresses, the rest are
172.16.0.0 – 172.31.255.255, public.
192.168.0.0 – 192.168.255.255
Routing to the Internet
● One day your supervisor walks to you, saying: Here is the network ID
192.168.4.0/24. Please create three separate networks or subnets for
BITS College. One subnet is for the Finance office, one is for the
Registrar and one is for public use. Your task is to list each network
ID, subnet mask, Host ID Range, # of usable host IDs, and Broadcast
ID.
Subnet # of
Network ID Mask Host ID Range usable Broadcast ID
host
64 is the total number of host IDs for each network. But the first host ID
is reserved for network ID, and the last host ID is reserved for broadcast
ID. Thus, the number of usable host ID is 64 minus 2, which is 62.
IPv4 – Subnetting
Subnetting Formula
1. Amount of subnets = 2subnet bits
2. Amount of hosts per subnet = 2host bits - 2
o (-2 for broadcast and subnet number)
3. Base number = 256 - subnet mask
4. Broadcast address = next subnet - 1
5. First valid host = subnet + 1
6. Last valid host = broadcast - 1
o (valid hosts must not be all 0’s or all 1’s)
How many subnets? 2x = number of subnets. x is the number of masked bits, or the 1s. For
example, in 11000000, the number of ones gives us 22 subnets. In this example, there are 4 subnets.
How many hosts per subnet? 2x – 2 = number of hosts per subnet. x is the number of unmasked
bits, or the 0s. For example, in 11000000, the number of zeros gives us 26 – 2 hosts. In this
example, there are 62 hosts per subnet.
What are the valid subnets? 256 – subnet mask = block size, or base number. For example, 256 –
192 = 64. 64 is the first subnet. The next subnet would be the base number itself, or 64 + 64 = 128,
(the second subnet).
You keep adding the base number to itself until you reach the value of the subnet mask, which is
not a valid subnet because all subnet bits would be turned on (1s).
What’s the broadcast address for each subnet? The broadcast address is all host bits turned on,
which is the number immediately preceding the next subnet.
What are the valid hosts? Valid hosts are the numbers between the subnets, minus all 0s and all
1s.
Classless Inter-Domain Routing (CIDR)
255.0.0.0 = / 8
255.255.0.0 = /16
255.255.255.0 = /24
255.255.255.128 = /25
255.255.255.192 = /26
255.255.255.224 = /27
255.255.255.240 = /28
255.255.255.248 = /29
255.255.255.252 = /30
CIDR is really just the method that ISP’s (Internet Service Providers) use to allocate an amount of
addresses to a company, home - a customer.
They provide addresses in a certain block size - something we will be going into in greater detail
later in this chapter.
So when you receive a block of addresses from an ISP, what you’ll get will look something like
this: 192.168.10.32/28. What this is telling you is what your subnet mask is.
The slash notation (/) means how many bits are turned on (1’s). Obviously, the maximum could
only be /32 because a byte is 8 bits and there are four bytes in an IP address: (4×8=32). In the
example, 192.168.10.32/28 means the address range provided including subnet and broadcast is
192.168.10.32 – 192.168.10.47.
But keep in mind that the largest subnet mask available (regardless of the class of address) can
only be a /30 because you’ve got to keep at least two bits for host bits.
What do we know?
When we see a CIDR or subnet mask, we need to ask “what do we know about this?”
Easy Subnetting – Example 1
Subnets? 64.
Hosts? 2.
Valid subnets? 256 – 252 = 4 which gives us our block size. Start with 0 and keep adding
the block size to get our valid subnets. 0, 4, 8, 12, etc., all the way to 252.
Broadcast address for each subnet? Always the number right before the next subnet.
Valid hosts? The numbers between the subnet number and the broadcast address.
It is very common to use 255.255.255.252 or /30 bit mask on point-to-point links. Although you
can use a larger range, since there is only two possible hosts on a point-to-point link, it makes
sense to assign a /30 network to it. Doing this we can save on valuable IP addresses. Each subnet
supports 2 addresses per subnet, 4 total addresses (equals block size) where the first address is for
the network and the last address is the broadcast address.
Subnetting Questions
1. Which mask would you assign if you had a class c address with a requirement for a
minimum of 35 hosts per network to maximize your address space? (Hint: Think block
size!)
255.255.255.0 = 254 hosts per subnet
Always round up. It can be quite difficult to change the subnet mask after you have
assigned adjacent address space, or if the expanded range starts on another
address. Although it is a good practice to conserve address space wherever possible, it may
become necessary to allocate, reserve or pre-assign address space based on a capacity
requirement, potential, or perceived need. Note: You will need to run a classless routing
protocol in order to subnet address space utilizing VLSM.
2. You have a Class C address and need 5 usable subnets, each capable of accommodating at
least 18 hosts. What is your mask?
255.255.255.0 = 254 hosts per subnet
192.168.0.0/27
192.168.0.32/27
192.168.0.64/27
192.168.0.96/27
192.168.0.128/27
3. You have a class C /28 subnet mask. Which are valid hosts?
A. 192.168.28.33
B. 192.168.28.112
C. 192.168.28.119
D. 192.168.28.126
E. 192.168.28.175
F. 192.168.28.208
As with the previous question, it is easier then it looks. We are subnetting only in the fourth
octet.
Since this is a 240 mask (block size of 16) our valid subnets are 0, 16, 32, 48, 64, 80, 96,
112, 128, 144, 160, 176, 192, 208, 224 and 240.
Is a valid host
Is a subnet address
Is a valid host
Is a valid host
Is a broadcast address
Is a subnet address