3 - IPv4 – Addressing and Subnetting

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

IPv4 Addressing

Binary Numbering

● IP addresses are 32 bits long.


● The 32 bits are divided into four octets (8-bits).
● A value in binary is represented by the number (0 or 1) in each
position multiplied by the number 2 to the power of the position of the
number in sequence, starting with 0 and increasing to 7, working right
to left.
128 64 32 16 8 4 2 1

1*2^7 1*2^6 1*2^5 1*2^4 1*2^3 1*2^2 1*2^1 1*2^0


IP Address Structure
● IP addresses are 32 bits long
● IP addresses are divided into four sections of one byte (octet) each
● IP addresses are typically written in a format known as dotted decimal
● IP addresses are further subdivided into two sections known as
network and host.

In binary notation In decimal notation


Subnet Mask
● To separate network addresses from host addresses, IPv4 uses an
additional component with IP addresses. This component is known
as a subnet mask.
● In other words, in an IP address, how many bits are used in the
network address and how many bits are left for the host address is
determined by the subnet mask.
● The subnet mask is also 32 bits in length and uses the same
notation that is used by the IP address.
● In binary notation, 1 (one) represents an ON bit while 0 (zero)
represents an OFF bit. In dotted-decimal notation, a value range 1 to
255 represents an ON bit while a value 0 (zero) represents an OFF
bit.
Subnet Mask
In binary notation In decimal notation

Following are the examples of IP addresses with subnet mask in decimal


notation: -
IP addresses in IPv6
● IPv6 addresses are 128 bits in length.
● These bits are divided into eight equal sections.
● Sections are separated by colons (:) and written in a sequence.
● IPv6 addresses are written in hexadecimal notation.
● The following image shows how bits are arranged in IPv6 addresses.
IP addresses in IPv6
● Following are the examples of IP addresses in IPv6:

● Instead of using an additional component to separate network addresses


and host addresses, IPv6 defines the number of bits for both types of
addresses.
IP addresses in IPv6

● 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 0.0.0.0 - 127.0.0.0 /8 or 255.0.0.0

B 128.0.0.0 - 191.255.0.0 /16 or 255.255.0.0

C 192.0.0.0 - 223.255.255.0 /24 or 255.255.255.0

D 224.0.0.0 - 239.255.255.255 /32 or 255.255.255.255

E 240.0.0.0 - 255.255.255.255 /32 or 255.255.255.255


IPv4 Address Classes
● Class D IP addresses are reserved for multicast applications.
● Class E IP addresses are reserved for broadcast traffic.
● Network and Host Addresses available for each class of IP address

Class Network Address Host Address

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

● Network Address Translation (NAT) translate private IPv4 addresses


○ NAT is typically enabled on the edge router connecting to the internet
● Port Address Translation (PAT):
○ In PAT, Private IP addresses
are translated into the public
IP address via Port numbers
Subnet an IPv4 Network
● Subnetting is a logical subdivision of an IP network.
● The process of dividing a network into two or more networks is called
subnetting.
● There are lots of reasons to utilize ip subnetting. Some of the benefits
include:
○ Reduced network traffic
○ Optimized network performance
○ Simplified management
○ Facilitates spanning of large geographical distances
○ Security is another benefit of subnetting.
Example #1

● 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

192.168.4.0 /26 192.168.4.1 - 192.168.4.62 62 192.168.4.63

192.168.4.64 /26 192.168.4.65 - 192.168.4.126 62 192.168.4.127

192.168.4.128 /26 192.168.4.129 - 192.168.4.190 62 192.168.4.191

192.168.4.192 /26 192.168.4.193 - 192.168.4.254 62 192.168.4.255

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

 How many subnets?


o Since 128 is one bit on (10000000), the answer would be 21 = 2.
 How many hosts per subnet? We have 7 host bits off (10000000), so the equation would
be 27 – 2 = 126 hosts.
 What are the valid subnets? 256 – 128 = 128, which our block size. Start with 0 and keep
adding the block size to get our valid subnets.
o Our valid subnets are, then, 0 and 128.
 What’s the broadcast address for each subnet? The number right before the next subnet
is all host bits turned on and equals the broadcast address.
 What are the valid hosts? These are the numbers between the subnets. The easiest way to
find the hosts is to write out the subnet address and the broadcast address. This way the
valid hosts are obvious.

Now, implement it…

Router# show ip route


OUTPUT
C 192.168.10.0 is directly connected to FastEthernet 0/0
C 192.168.10.128 is directly connected to FastEthernet 0/1

Easy Subnetting – Example 2

 Since 192 is two bits on (11000000), the answer would be 22 = 4.


 How many hosts per subnet? We have 6 host bits off (11000000), so the equation would
be 26 – 2 = 62 hosts.
 What are the valid subnets? 256 – 192 = 64, which gives us our block size. Start with 0
and keep adding the block size to get our valid subnets.
o Our valid subnets are, then, 0, 64, 128 and 192.
 What’s the broadcast address for each subnet? The number right before the next subnet
is all host bits turned on and equals the broadcast address.
 What are the valid hosts? These are the numbers between the subnets and the broadcast
address. The easiest way to find the hosts is to write out the subnet address and the
broadcast address. This way the valid hosts are obvious.
Now, implement it…
Easy Subnetting – Example 3

 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.

Now, implement it…

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

255.255.255.128 = 126 hosts per subnet

255.255.255.192 = 62 hosts per subnet – Correct Answer

255.255.255.224 = 30 hosts per subnet

255.255.255.240 = 14 hosts per subnet

255.255.255.248 = 6 hosts per subnet

255.255.255.252 = 2 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

255.255.255.128 = 126 hosts per subnet

255.255.255.192 = 62 hosts per subnet

255.255.255.224 = 30 hosts per subnet (Correct answer)

255.255.255.240 = 14 hosts per subnet

255.255.255.248 = 6 hosts per subnet

255.255.255.252 = 2 hosts per subnet


If the Class C address space is 192.168.0.0/24 then your subnets will be as follows:

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

4. What is the host IP and default gateway address?


The host address can be any unused IP address in the range. A /28 mask is a block size of
16, so the subnets are 0, 16, 32, 48…The routers interface is in the 16 subnet, so the host
range is 17-30.
The default gateway configured on the host would be the routers Fa1/1 interface address
which is 192.168.100.17. Remember, switches are layer 2 devices by default (although a
lot of switches these days are layer 3 capable). In this case we are treating the switch as a
layer 2 device so the default gateway needs to be an address on a layer 3 device which is
the Fa1/1 interface of the router.

You might also like