0% found this document useful (0 votes)
3 views

IP addressing and Subnetting

The document provides an overview of IP addressing, specifically focusing on IPv4, including the structure of IP addresses, the distinction between network and host portions, and types of addresses such as network, broadcast, and host addresses. It also discusses public and private addresses, subnetting, and the use of subnet masks to define network and host portions. Additionally, it covers historic network classes and provides formulas for calculating subnets and hosts within a network.

Uploaded by

Biju Kuttan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

IP addressing and Subnetting

The document provides an overview of IP addressing, specifically focusing on IPv4, including the structure of IP addresses, the distinction between network and host portions, and types of addresses such as network, broadcast, and host addresses. It also discusses public and private addresses, subnetting, and the use of subnet masks to define network and host portions. Additionally, it covers historic network classes and provides formulas for calculating subnets and hosts within a network.

Uploaded by

Biju Kuttan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

IP addressing-1

IP addressing

Each device on a network must be uniquely defined. At the Network


layer, the packets of the communication need to be identified with the
source and destination addresses of the two end systems. With IPv4,
this means that each packet has a 32-bit source address and a 32-bit
destination address in the Layer 3 header.

These addresses are used in the data network as binary patterns.


Inside the devices, digital logic is applied for their interpretation.
For us in the human network, a string of 32 bits is difficult to
interpret and even more difficult to remember. Therefore, we represent
IPv4 addresses using dotted decimal format.

Network and Host Portions

For each IPv4 address, some portion of the high-order bits represents
the network address. At Layer 3, we define a network as a group of
hosts that have identical bit patterns in the network address portion
of their addresses.

Although all 32 bits define the IPv4 host address, we have a variable
number of bits that are called the host portion of the address. The
number of bits used in this host portion determines the number of
hosts that we can have within the network.

This part represents the network portion:


IP addressing-2

This part represents the host portion

Types of address in an IPv4 network:

Within the address range of each IPv4 network, we have three types of
addresses:

• Network address - The address by which we refer to the network


• Broadcast address - A special address used to send data to all hosts
in the network
• Host addresses - The addresses assigned to the end devices in the
network

Network Address

The network address is a standard way to refer to a network. For


example, we could refer to the network shown in the figure as "the
10.0.0.0 network." This is a much more convenient and descriptive way
to refer to the network than using a term like "the first network."
All hosts in the 10.0.0.0 network will have the same network bits.

Within the IPv4 address range of a network, the lowest address is


reserved for the network address. This address has a 0 for each host
bit in the host portion of the address.

Broadcast Address

The IPv4 broadcast address is a special address for each network that
allows communication to all the hosts in that network. To send data to
all hosts in a network, a host can send a single packet that is
addressed to the broadcast address of the network.

The broadcast address uses the highest address in the network range.
This is the address in which the bits in the host portion are all 1s.
For the network 10.0.0.0 with 24 network bits, the broadcast address
would be 10.0.0.255. This address is also referred to as the directed
broadcast.

Host Addresses

Every end device requires a unique address to deliver a packet to that


host. In IPv4 addresses, we assign the values between the network
address and the broadcast address to the devices in that network.
IP addressing-3

Network Prefixes

How do we know how many bits represent the network portion and how
many bits represent the host portion? When we express an IPv4 network
address, we add a prefix length to the network address. The prefix
length is the number of bits in the address that gives us the network
portion. For example, in 172.16.4.0 /24, the /24 is the prefix length
- it tells us that the first 24 bits are the network address. This
leaves the remaining 8 bits, the last octet, as the host portion.

Networks are not always assigned a /24 prefix. Depending on the number
of hosts on the network, the prefix assigned may be different. Having
a different prefix number changes the host range and broadcast address
for each network.

Calculating network, host and broadcast addresses

In the first box, we see the representation of the network address.


With a 25 bit prefix, the last 7 bits are host bits. To represent the
network address, all of these host bits are '0'. This makes the last
octet of the address 0. This makes the network address 172.16.20.0/25.
In the second box, we see the calculation of the lowest host address.
This is always one greater than the network address. In this case, the
last of the seven host bits becomes a '1'. With the lowest bit of host
address set to a 1, the lowest host address is 172.16.20.1. The third
box shows the calculation of the broadcast address of the network.
Therefore, all seven host bits used in this network are all '1s'. From
IP addressing-4

the calculation, we get 127 in the last octet. This gives us a


broadcast address of 172.16.20.127. The fourth box presents the
calculation of the highest host address. The highest host address for
a network is always one less than the broadcast. This means the lowest
host bit is a '0' and all other host bits as '1s'. As seen, this makes
the highest host address in this network 172.16.20.126.

Public and private address

Although most IPv4 host addresses are public addresses designated for
use in networks that are accessible on the Internet, there are blocks
of addresses that are used in networks that require limited or no
Internet access. These addresses are called private addresses.

Public Addresses

The vast majority of the addresses in the IPv4 unicast host range are
public addresses. These addresses are designed to be used in the hosts
that are publicly accessible from the Internet. Even within these
address blocks; there are many addresses that are designated for other
special purposes.

Private Addresses

The private address blocks are:

10.0.0.0 to 10.255.255.255 (10.0.0.0 /8)


172.16.0.0 to 172.31.255.255 (172.16.0.0 /12)
192.168.0.0 to 192.168.255.255 (192.168.0.0 /16)
IP addressing-5

Private space address blocks, as shown above, are set aside for use in
private networks. The use of these addresses need not be unique among
outside networks. Hosts that do not require access to the Internet at
large may make unrestricted use of private addresses. However, the
internal networks still must design network address schemes to ensure
that the hosts in the private networks use IP addresses
that are unique within their networking environment.

Many hosts in different networks may use the same private space
addresses. Packets using these addresses as the source or destination
should not appear on the public Internet. The router or firewall
device at the perimeter of these private networks must block or
translate these addresses. Even if these packets were to make their
way to the Internet, the routers would not have routes to forward them
to the appropriate private network.

Network Address Translation (NAT)

With services to translate private addresses to public addresses,


hosts on a privately addressed network can have access to resources
across the Internet. These services, called Network Address
Translation (NAT), can be implemented on a device at the edge of the
private network.

NAT allows the hosts in the network to "borrow" a public address for
communicating to outside networks. While there are some limitations
and performance issues with NAT, clients for most applications can
access services over the Internet without noticeable problems.

Historic Network Classes:

1. Class A Blocks

A class A address block was designed to support extremely large


networks with more than 16 million host addresses. Class A IPv4
addresses used a fixed /8 prefix with the first octet to indicate the
network address. The remaining three octets were used for host
addresses. To reserve address space for the remaining address classes,
all class A addresses required that the most significant bit of the
high-order octet be a zero. This meant that there were only 128
possible class A networks, 0.0.0.0 /8 to 127.0.0.0 /8, before taking
out the reserved address blocks. Even though the class A addresses
reserved one-half of the address space, because of their limit of 128
networks, they could only be allocated to approximately 120 companies
or organizations.

2. Class B Blocks

Class B address space was designed to support the needs of moderate to


large size networks with more than 65,000 hosts. A class B IP address
used the two high-order octets to indicate the network address. The
other two octets specified host addresses. As with class A, address
space for the remaining address classes needed to be reserved. For
IP addressing-6

class B addresses, the most significant two bits of the high-order


octet were 10. This restricted the address block for class B to
128.0.0.0 /16 to 191.255.0.0 /16. Class B had slightly more efficient
allocation of addresses than class A because it equally divided 25% of
the total IPv4 address space among approximately 16,000 networks.

3. Class C Blocks

The class C address space was the most commonly available of the
historic address classes. This address space was intended to provide
addresses for small networks with a maximum of 254 hosts. Class C
address blocks used a /24 prefix. This meant that a class C network
used only the last octet as host addresses with the three high-order
octets used to indicate the network address.

Class C address blocks set aside address space for class D (multicast)
and class E (experimental) by using a fixed value of 110 for the three
most significant bits of the high-order octet. This restricted the
address block for class C to 192.0.0.0 /16 to 223.255.255.0/16.
Although it occupied only 12.5% of the total IPv4 address space, it
could provide addresses to 2 million networks.

The subnet mask – defining the network and host portions

An IPv4 address has a network portion and a host portion. We referred


to the prefix length as the number of bits in the address giving us
the network portion. The prefix is a way to define the network portion
that is human readable. The data network must also have this network
portion of the addresses defined. To define the network and host
portions of an address, the devices use a separate 32-bit
pattern called a subnet mask. We express the subnet mask in the same
dotted decimal format as the IPv4 address. The subnet mask is created
by placing a binary 1 in each bit position that represents the network
portion and placing a binary 0 in each bit position that represents
the host portion. The prefix and the subnet mask are different ways of
representing the same thing – the network portion of an address.
IP addressing-7

A /24 prefix is expressed as a subnet mask as 255.255.255.0


(11111111.11111111.11111111.00000000). The remaining bits (low order)
of the subnet mask are zeroes, indicating the host address within the
network.

The subnet mask is configured on a host in conjunction with the IPv4


address to define the network portion of that address.

For example, let's look at the host 172.16.20.35/27:

• Address
172.16.20.35
10101100.00010000.00010100.00100011

• subnet mask
255.255.255.224
11111111.11111111.11111111.11100000

• network address
172.16.20.32
10101100.00010000.00010100.00100000

Because the high order bits of the subnet masks are contiguous 1s,
there are only a limited number of subnet values within an octet. You
will recall that we only need to expand an octet if the network and
host division falls within that octet. Therefore, there are a limited
number 8 bit patterns used in address masks.

These patterns are:

• 00000000 = 0
• 10000000 = 128
• 11000000 = 192
• 11100000 = 224
• 11110000 = 240
IP addressing-8

• 11111000 = 248
• 11111100 = 252
• 11111110 = 254
• 11111111 = 255

If the subnet mask for an octet is represented by 255, then all the
equivalent bits in that octet of the address are network bits.
Similarly, if the subnet mask for an octet is represented by 0, then
all the equivalent bits in that octet of the address are host bits. In
each of these cases, it is not necessary to expand this octet to
binary to determine the network and host portions.

The IPv4 host address is logically AND ed with its subnet mask to
determine the network address to which the host is associated. When
this AND ing between the address and the subnet mask is performed, the
result yields the network address.

Basic subnetting

Subnetting allows for creating multiple logical networks from a single


address block. Since we use a router to connect these networks
together, each interface on a router must have a unique network ID.
Every node on that link is on the same network. We create the subnets
by using one or more of the host bits as network bits. This is done by
extending the mask to borrow some of the bits from the host portion of
the address to create additional network bits. The more host bits
used, the more subnets that can be defined. For each bit borrowed, we
double the number of subnetworks available. For example, if we borrow
1 bit, we can define 2 subnets. If we borrow 2 bits, we can have 4
subnets. However, with each bit we borrow, fewer host addresses are
available per subnet.

Router-A in the figure has two interfaces to interconnect two


networks. Given an address block of 192.168.1.0/24, we will create two
subnets. We borrow one bit from the host portion by using a subnet
mask of 255.255.255.128, instead of the original 255.255.255.0 mask.
The most significant bit in the last octet is used to distinguish
between the two subnets. For one of the subnets, this bit is a "0" and
for the other subnet this bit is a "1".
IP addressing-9

Formula for calculating subnets

Use this formula to calculate the number of subnets:

2^n where n = the number of bits borrowed. In this example, the


calculation looks like this:
2^1 = 2 subnets

The number of hosts

To calculate the number of hosts per network, we use the formula of


2^n - 2
where n = the number of bits left for hosts. Applying this formula,
(2^7 - 2 = 126) shows that each of these subnets can have 126 hosts.

For each subnet, examine the last octet in binary. The values in these
octets for the two networks are:

Subnet 1: 00000000 = 0
Subnet 2: 10000000 = 128

* END *
IP addressing-10

Lab Exercise

1. Calculate Network address, broadcast address and the range of host


address.

2. Find Network address for the following ip address.


IP addressing-11

3. Find which of the following IPs are private IPs and which are
public IPs
IP addressing-12

> Private IP addresses

> RFC 1918 name - 24 bit block

10.0.0.0/8 (255.0.0.0) - Network prefix and subnet mask


IP address range - 10.0.0.0 to 10.255.255.255
Single class A network - 16777216 addresses
Host ID - 24 bits
Network bits or Mask bits - 8 bits

> RFC 1918 name - 20 bit block

172.16.0.0/12 (255.240.0.0) - Network prefix and subnet mask


IP address range - 172.16.0.0 to 172.31.255.255
16 contiguous class B networks - 1048576
Host ID - 20 bits
Network bits or Mask bits - 12 bits

> RFC 1918 name - 16 bit block

192.168.0.0/16 (255.255.0.0) - Network prefix and subnet mask


IP address range - 192.168.0.0 to 192.168.255.255
256 contiguous class C networks - 65536
Host ID - 16 bits
Network bits or Mask bits - 16 bits

* END *
Subnetting-1
> What is IP Address

It is a number containing 4 octets (bytes) separated by dots. Each octet can have a total of
256 values (0 - 255). It is used to identify the source and destination machine when
transmitting data through the internet.

Example:
192.168.0.1 [ Dotted Decimal Notation – Base 256 ]
10.1.0.255
255.255.255.0

> Understanding powers of 2

2^1= 2
2^2= 4
2^3= 8
2^4= 16
2^5= 32
2^6= 64
2^7= 128
2^8= 256

> Binary Number Tricks

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

1 0 0 0 0 0 0 0 = 128
1 1 0 0 0 0 0 0 = 192 [ 128 + 64 ]
1 1 1 0 0 0 0 0 = 224 [ 128 + 64 + 32 ]
1 1 1 1 0 0 0 0 = 240 [ 128 + 64 + 32 + 16 ]

0 1 1 1 1 1 1 1 = 127

0 0 0 0 1 1 1 1 = 15 [ 8 + 4 + 2 + 1 ]

0 = 255
-1 = 254
-2 = 252
-4 = 248
-8 = 240

> Why IP address is structured as heirarchical address as opposed to flat


( non-heirarchical ) address ?

There are two advantages for heirarchical addressing scheme:

One it can handle a large number of addresses(4.3 billion). Second is related to routing.
If every address were unique all routers on the internet would need to store address of
each and every machine on the internet. This would make effecient routing impossible.
Subnetting-2
The solution to this problem is to use a two or three level, heirarchical addressing
scheme that is structured by network and host or network, subnet and host. Rather than
all 32 bits being treated as a unique identifier as in flat addressing, a part of the address is
designated as network address and the other is designated as either the subnet or just the
node address.

> Classful IP addressing

There are three usable IP address classes - A, B and C. The first byte identifies the class.

Class First Networks Host MSB Bits in ….


Octet Net Host
ID ID
A 1 – 127 127 16,777,214 0 7 24
B 128 - 191 16,384 65,534 10 14 16
C 192 - 223 2,097,151 254 110 21 8
D 224 - 239 Multicast 111
E 240 - 255 DoD Reserved 1111

Calculating Total number of Networks

Classes Total number of Network per class


Class A 01111111.00000000.00000000.00000000 = 2 ^ 7 = 127
Class B 10111111.11111111.00000000.00000000 = 2 ^ 14 = 16,384
Class C 11011111.11111111.11111111.00000000 = 2 ^ 21 = 2,097,152

Calculating Total number of Hosts

Classes Total number of Hosts per class


Class A 00000000.11111111.11111111.11111111 = 2 ^ 24 – 2 = 16,777,214
Class B 00000000.00000000.11111111.11111111 = 2 ^ 16 – 2 = 65,534
Class C 00000000.00000000.00000000.11111111 = 2 ^ 8 – 2 = 254

> Various Classes of IP addresses

Class A - 1 octet for Network + 3 octet for Host [ 1N+3H ]


Class B - 2 octet for Network + 2 octet for Host [ 2N+2H ]
Class C - 3 octet for Network + 1 octet for Host [ 3N+1H ]
Class D - Multicast
Class E - Research

> Rules for each classes

Class A - First bit of first octet is 0 [ from 0 - 127 ]


Class B - First two bits of first octet is 10 [starts from 128]
Class C - First three bits of first octet is 110 [starts from 192]
Class D - First four bits of first octet is 1110 [starts from 224]
Class E - First four bits of first octet is 1111 [starts from 240]
Subnetting-3

Class to which a network belongs can be identified from the value of the first octet.

Class A - [ 0 - 127 ]
Class B - [ 128 - 191 ]
Class C - [ 192 - 223 ]
Class D - [ 224 - 239 ]
Class E - [ 240 - 255 ]

Class A network [ 1N + 3H ]

First octet = 0000 0000 [ 0 to


0111 1111 [ 127

Networks possible = 2^7 = 128


Usable Network = 2^7 - 2 = 128-2 = 126 [1 to 126]

Hosts Possible = 2 ^ 24 = 16,777,216


Valid Host IDs = 2 ^ 24 - 2 = 16,777,214

NOTE: Network address of all Zeroes and 127 is reserved. Host address of all Zeroes
and all ones is also reserved.

Class B network [ 2N + 2H ]

First octet = 1000 0000 [ 128 to


1011 1111 191 ]

Networks Possible = 2 ^ 14 = 16,384

Hosts Possible = 2 ^ 16 = 65,536


Valid Host IDs = 2 ^ 16 - 2 = 65,534

Class C network [ 3N + 1H ]

First octet = 1100 0000 [ 192 to


1101 1111 223 ]

Networks Possible = 2 ^ 21 = 2,097,152

Hosts Possible = 2 ^ 8 = 256


Valid Host IDs = 2 ^ 8 - 2 = 254

> Special purpose IP addresses

127.0.0.1 - Loopback address


0.0.0.0 - Default route
255.255.255.255 - All 1s broadcast. Broadcast to all nodes on current network.
Subnetting-4

Network address of all 1s - Means "all Networks"


Network address of all 0s - Means "this network"
Node address of all 0s - Indicate Network address
Node address of all 1s - Indicate all nodes on the specified network

Reserved Addresses

127.0.0.1 – 127.255.255.255

Reserved for testing and loopback routines for IP applications.


ping 127.0.0.1 - verifies the local host has properly loaded the IP protocol.

224.0.0.1 - 224.0.0.255 [ Class D multicast ]

Reserved for well known services and network topology mechanisms.

> Subnetting

Means divide a big network into logical groups.

> Why Subnetting

Imagine an organization that has 500 employees connected to single network. Each
employee is assigned a unique IP address. All the employees use the network for both
official and personal use. In this scenario, due to heavy traffic(transfer of data), the
packets become slow resulting in collision and retransmission. As there is no security
critical data can be accessed by any employee.

Subnetting is used to regulate IP traffic. It improves network security and performance by


organizing hosts into logical groups.

> What is Subnet

Subnet is a portion of network that uses bits from the host portion of the IP address and
reserves them to define a subnet address. The more the subnets, the less the bits available
for defining hosts.

> Use of Subnet mask

To identify the network and host parts of the IP address.

The network bits are represented by the 1's in the mask.


The host bits are represented by the 0's in the mask.

The result of a bit-wise logical 'AND' operation between the IP address and the subnet
mask is a Network Address or Subnet Address.
Subnetting-5
There are three default subnet masks :

Class A - 255.0.0.0 - 11111111.00000000.00000000.00000000


Represents - Network.Host.Host.Host

Class B - 255.255.0.0 - 11111111.11111111.00000000.00000000


Represents - Network.Network.Host.Host

Class C - 255.255.255.0 - 11111111.11111111.11111111.00000000


Represents - Network.Network.Network.Host

> Finding Network Address of IP address 140.130.240.200

It is a Class B IP address. Its default subnet mask is 255.255.0.0. After performing


bitwise logical AND, you will get the Network address as 140.130.0.0

> What is Subnetting. What are its benefits ?

Subnetting is the process of splitting a single large network into a group of small
connected networks. Benefits of subnetting are:

- Reduced Network traffic : Routers create broadcast domains. Smaller the broadcast
domain you create lesser the network traffic on that network segment.

- Optimized network performance

- Simplified network management : It is easy to identify and isolate network problems in


a group of small connected networks than in a single big network.

- Facilitated spanning of large geographical distances.

> How subnetting is done ?

Subnets are created by taking bits from the host portion of the IP address and reserve
them to define Subnets. More the subnets, fewer the bits available for defining hosts.

> What are the things to consider before Subnetting

- Determine the number of Subnet IDs required.


- One for each Subnet.
- One for each Wide area network connection.

- Determine the number of Host IDs required for each subnet.


- One for each host.
- One for each router interface.

Based on details above, determine Subnet Mask for entire network, Subnet ID for each
subnet and range of host IDs for each Subnet.
Subnetting-6
To correctly subnet a given network address into subnet addresses, ask
yourself the following questions:
- How many bits do I need to borrow ?
- What’s the subnet mask ?
- What’s the “magic number” or Blocksize ?
- What are the first three subnetwork addresses ?

> How many bits do I have to work with ?

Depends on the class of your network address.


Class C: 8 host bits
Class B: 16 host bits
Class A: 24 host bits

Remember: you must borrow at least 2 bits for subnets and leave at
least 2 bits for host addresses.
2 bits borrowed allows 2^2 - 2 = 2 subnets

> How many subnets or hosts do I need ?

A simple formula:
Total Bits = Bits Borrowed + Bits Left
TB = BB + BL

I need X subnets: 2^BB - 2 >= X


I need X hosts: 2^BL - 2 >= X

Remember: we need to subtract two to provide for the subnetwork and broadcast
addresses.

> What is a Subnet Mask

Subnet Mask is a 32-bit value composed of 1s and 0s, which allows the
host to determine which part of the IP address represents network ID
and which part represents Host ID. The 1s in the Subnet mask
represent the positions that refer to network address.

For Class A addresses, subnet mask must start at 255.0.0.0


For Class B addresses, subnet mask must start at 255.255.0.0
For Class C addresses, subnet mask must start at 255.255.255.0

Maximum value of Subnet mask can only be /30 (255.255.255.252)


Because atleast 'two' bits must be kept for defining hosts.

Minimum value of Subnet mask can only be /8 (255.0.0.0)


Subnetting-7
> Subnetting Class C address

In class C address only 8 bits are available for defining hosts. So the only class C subnet
masks possible are:

1000 0000 = 128 = /25 (Subnet Zero - Invalid)


1100 0000 = 192 = /26
1110 0000 = 224 = /27
1111 0000 = 240 = /28
1111 1000 = 248 = /29
1111 1100 = 252 = /30
1111 1110 = 254 = /31 (Invalid)

NOTE:
Assigning only 1 bit for Subnet is called Subnet Zero. Although it is used in production
environment, for CCNA exam it is invalid.

Maximum value of Subnet mask can only be /30, because atleast two bits must be kept
for host.

Subnet bits cannot be All Zero or All One at the same time.

> Example for Subnetting a Class C address.

Subnet mask = 255.255.255.192 (Last Octet = 1100 0000)

Subnet bits used = 2


Subnets possible = 2 ^ 2 - 2 = 4 - 2 = 2
1) 0100 0000
2) 1000 0000

Host Bits = 6
Hosts Possible = 2 ^ 6 = 64
Valid hosts = 64 - 2 = 62
Each Subnet will have 62 valid host IDs

Subnet Host Meaning


-------- ------ ------------
01 00 0000 = 64 The network address
01 00 0001 = 65 First Valid host (Net.Address + 1)
01 11 1110 = 126 Last Valid host (Broadcast - 1)
01 11 1111 = 127 Broadcast address

Subnet Host Meaning


-------- ------ ------------
10 00 0000 = 128 The network
10 00 0001 = 129 First Valid host
10 11 1110 = 190 Last Valid host
10 11 1111 = 191 Broadcast address
Subnetting-8

> Faster Method (Subnetting Class C address)

Subnet mask = 255.255.255.224

Subnet bits = 3
Subnets Possible = 2 ^ 3 - 2 = 6
Host bits = 5
Host Possible = 2 ^ 5 - 2 = 30

Block Size/Base number/Magic number = 256 - 224 = 32

Create the table below by writing down all the subnets by adding block size:

Subnets - 32 64 96 128 160 192


First Host - 33 65 97 129 161 193
Last Host - 62 94 126 158 190 222
Broadcast - 63 95 127 159 191 223

> Subnetting Class B address

Class B network address has 16 bits available for host addressing. We can use upto 14
bits for subnetting.

Mask start from /17 = 255.255.128.0


Upto /30 = 255.255.255.252

> Subnetting Class A address

Class A network address has 24 bits available for host addressing. We can use upto 22
bits for subnetting.

Mask start from /9 = 255.128.0.0


Upto /30 = 255.255.255.252

> Subnetting TIPS

Subnet bits = x
Subnets possible = 2 ^ x - 2

Host bits = y
Block Size = 2 ^ y (or 256 - mask)
Valid Hosts = 2 ^ y - 2

BlockSize = 256 - mask


This will be always powers of 2 starting from a minimum of 4 (2^2).
Subnetting-9
BlockSize Mask
--------- -------
4 /30
8 /29
16 /28
32 /27
64 /26
128 /25
256 /24

> Private Subnets

For each class of IP Addresses, there is a set of IP addresses reserved for private
networks. They are :

Class A - 10.0.0.0/8
Class B - 172.16.0.0/12
Class C - 192.168.0.0/16

These IP addresses can be used for setting up internal IP networks at Home, Labs and
LANs behind a NAT or proxy server or router. They are always safe to use because
routers on the Internet will never forward packets coming from these addresses.

> How does the use of Private IP address saves valuable IP address space ?

If every host on the network had to have real routable IP addresses, we would have run
out of IP addresses years ago. But by using private IP addresses - ISPs, corporations and
home users only need a small group of real routable IP address to connect their network
to the internet. But when using private IP address for internal network it needs to be
translated to a routable IP address for connecting to the internet. To accomplish this task
we use NAT, which takes a private IP address and convert it for use on the internet.

> What is NAT (Network Address Translation) ?

NAT is a software which takes a private IP address and translates it into a real routable IP
address. NAT operates on a Cisco router. There are different flavors of NAT :
- Static NAT
- Dynamic NAT
- Overloading NAT (PAT)

Static NAT : Provides static one-to-one mapping of a private IP address to a public IP


address. It requires you to have one real public IP address for every host on your network.

Dynamic NAT : Here one-to-one mapping is Dynamic. An IP address is dynamically


assigned from a pool of registered IP address.

Overloading NAT : This Technique maps multiple unregistered IP address to a single


registered IP address (many-to-one) by using different ports. Therefore it is also known
Subnetting-10
as Port Address Translation(PAT). This allows thousand of users to connect to the
internet using one real public IP address.

> Exercise

> What is the network address for the IP address 12.10.200.100 ?

To get the network address, we have to find the subnet mask, because it separates the
network portion and host portion of the IP address. Since it is a class A IP address, the
default subnet mask is 255.0.0.0. Applying subnet mask, network address becomes
12.0.0.0

> You have been assigned a class C network number of 200.133.175.0. Break the
network into 14 subnets of 14 nodes each.

Step1. Find the subnet bits (n)


Step2. Find the subnet mask
Step3. Find block size
Step4. Create table

2 ^ n - 2 = 14
2 ^ n = 16
n=4

255.255.255.11110000
255.255.255.240

256 - 240 = 16

Subnets : 16 32 48 64 80 .. .. ..
First Host : 17 33 49 65 81 .. .. ..
Last Host : 30 46 62 78 94 .. .. ..
Broadcast : 31 47 63 79 95 .. .. ..

> What is the maximum number of subnets that can be assigned to networks when
using the address 131.107.0.0 with a subnet mask of 255.255.240.0

131.107.0.0 is a class B IP address. Its default subnet mask is 255.255.0.0. But the given
subnet mask is 255.255.240.0. So no of subnet bits used is 4. No of possible subnets are:

2 ^ 4 - 2 = 14 Subnets

> Using the address 192.64.10.0/28 how many subnets and hosts are available.

It is a class C IP address. So default subnet mask is 255.255.255.0 Here 4 subnet bits are
used which leaves 4 bits for host. So no of possible subnets and host are:
Subnetting-11
2 ^ 4 - 2 = 14 Subnet and
2 ^ 4 - 2 = 14 host.

> Given an IP address of 131.107.2.160 and a subnet mask of 255.255.255.192, to


which subnet does the host belong.

Step1. Find the block size


Step2. Create the table

Blocksize = 256 - 192 = 64

Subnet : 64 128 192


First Host : 65 129
Last Host : 126 190
Broadcast : 127 191

The IP address belong to subnet 131.107.2.128

> What is CIDR (Classless Inter Domain Routing)

CIDR is a technique used by ISPs to allocate a block of IP addresses to a customer. You


will get something like: 192.168.10.32/28
Here Slash notation(prefix) indicates the number of 1s in the Subnet mask.

> Disadvantages of Classful Subnet

The classful address system of allocating IP addresses can be very wasteful:

If somebody needs more than 254 hosts, they were automatically given a class B address
block which consist of 65534 host addresses. Most of them are simply not used.
Companies and organizations were allocated class A address block of over 16 million
host addresses. Only a tiny percentage of the allocated class A and class B address space
has ever been actually assigned to a host computer on the internet.

By eliminating class system addresses can be conserved. Accurately allocating only the
amount of address space that is actually needed to address can avoid space crisis for
many years.

> What is VLSM networking (Variable Length Subnet Mask)

VLSM networking is the process of taking one network and create many networks from it
using subnet masks of different length. Usually in classful routing all hosts and router
interfaces in a network have the same subnet mask. With VLSM we can have different
subnet masks for different subnets.

> What is classful routing and classless routing


Subnetting-12
If a router running routing protocols RIP.v1 or IGRP has a subnet mask of a certain
value, it assumes that all interfaces within the classful address space have the same
subnet mask. This is called classful routing. This happens because when using these
protocols subnet information gets dropped becuase they do not have fields for holding
subnet information.

RIP.v1 and IGRP are called classful routing protocols.

The problem with classful routing is that if you use subnet masks of different length in a
network running RIP.v1 and IGRP the network won't work. Also use of classful routing
protocols wastes valuable IP address space.

NOTE: In classful routing all hosts and router interfaces in a network have the same
subnet mask.

Classless routing allow us to use VLSM in a network running classless routing protocols.
RIP.v2, EIGRP and OSPF are classless routing protocols. These protocols support
advertisement of subnet information. Also use of VLSMs saves valuable IP address
space.

> What is Summarization

Summarization also called Supernetting provides route updates in efficient way by


advertising many routes in one advertisement instead of advertising each route
individually.

> Supernetting

Although internet is running out of Class B addresses, there are still class C addresses
available. With Supernetting it is possible to combine multiple class C addresses into the
equivalent of a class B. CIDR(Classless Inter Domain routing) was invented to keep the
internet from running out of IP addresses. Under CIDR, the subnet mask notation is
simplified, listing only 1s bits that start the mask. Classful addresses can easily be written
in CIDR notation.

Class A = /8
Class B = /16
Class C = /24

If you need about 1000 addresses, you could supernet 4 class C networks together:

192.60.128.0 (11000000.00111100.10000000.00000000) - Class C Subnet


192.60.129.0 (11000000.00111100.10000001.00000000) - Class C Subnet
192.60.130.0 (11000000.00111100.10000010.00000000) - Class C Subnet
192.60.131.0 (11000000.00111100.10000011.00000000) - Class C Subnet

192.60.128.0 - Supernetted subnet address


255.255.252.0 - 11111111.11111111.11111100.00000000 - Subnet mask
Subnetting-13
192.60.131.255 - Broadcast address

The subnet 192.60.128.0 includes all the addresses from 192.60.128.0 to 192.60.131.255.
Network portion of the address is 22 bits long and the host portion is 10 bits long.
According to CIDR notation, instead of writing the address and subnet mask as
192.60.128.0 and 255.255.252.0 respectively, the network address can be written as
192.60.128.0/22.

> Example

1. What is the network address for a host with IP address 123.200.8.68/28

.68 = 01000100
/28 = 11110000 (last octet)
AND ing = 01000000 = .64 [ OR use Blocksize Technique ]

Answer: 123.200.8.64

OR

1. Above is a class A address. Default subnet mask is 255.0.0.0


2. /28 means 8 + 8 + 8 + 4
3. ie: 255.255.255.11110000 or 255.255.255.240
4. Block size = 256 - 240 = 16
5. Subnet blocks
123.200.8.16
123.200.8.32
123.200.8.48
123.200.8.64 ==> (Subnet address)
123.200.8.80

> 4 Troubleshooting steps Cisco uses in a situation when a host cannot communicate
with the remote server.

1. Ping Loopback address(127.0.0.1). If it works then it is considered that TCP/IP stack is


initialized. If it fails, then you have an IP stack failure and need to reinstall TCP/IP on the
host.

2. Ping the IP address of localhost. It it works then your NIC card is functioning and the
TCP/IP stack on the host can communicate with the NIC. If it fails, there is a problem
with NIC card.

3. Ping the default gateway(router interface). If it works then your NIC can communicate
on the local network. It it fails then there is a physical network problem happening
anywhere from the NIC to the router.

4. Ping the remote server. If it works then there is IP communication between localhost
and remote server. If it fails then you have some type of remote physical network
Subnetting-14
problem. To troubleshoot it you must go to the server and work through steps 1 through 3
until you find the snag.

If user still can't communicate with the server after steps 1 through 4 are successful, then
you probably have some form of name resolution problem. Check your DNS settings.
Check for IP configuration errors.

> Classless subnetting or VLSM (Variable Length Subnet Masking)

Allows for more efficient use of IP space. Defined in RFC 1818. Less waste on smaller
subnets where fewer addresses are necessary. Used frequently if public address are used
internally.

> VLSM Problem 1

Using network 172.16.0.0. Create a mask for a subnet containing 90 hosts.

1. Identify the no.of host bits required.

2^n - 2 >= 90
2^n >= 92 [ 2^6 = 64, 2^7 = 128]
n = 7 host bits [remaining 25 network bits]

Subnet mask = 255.255.255.128/25

> VLSM Problem 2

Using network 10.0.0.0. Create a mask for a subnet containing 2 hosts.

1. Identify the no.of host bits required.

2^n – 2 >= 2
2^n >= 4
n = 2 host bits [remaining 30 network bits]

Subnet mask = 255.255.255.252/30

> VLSM Problem 3

Using network 10.0.0.0. Create a mask for a subnet containing 300 hosts.

1. Identify the no.of host bits required.

2^n - 2 >= 300


2^n >= 302 [2^8 = 256, 2^9 = 512]
n = 9 host bits [remaining 23 network bits]

Subnet mask = 255.255.254.0/23


Subnetting-15

> CIDR (Classless inter Domain Routing)

This method helps to control IP addresses depletion.

Reduce Internet routing table size (BGP Table).

Blocks of Contiguous Addresses (4, 8,16, etc) are assigned to ISPs. ISPs assign IP
addresses to Customers in contiguous blocks. Blocks are summarized to reduce router
advertisements and route table size.

> Supernetting, Summarization, Aggregation

* END *
Exercises-1

Classful Subnetting - Exercises

1.. Which of the following hardware devices can be used to segment your network.

a. Repeater
b. Switch
c. Router (Answer)
d. Media converter

2. Using a class C Address range 192.168.21.12, your network needs twenty eight
subnets. Which subnet mask should you use ?

Solution is in finding no.of subnet bits required.

2^n - 2 >= 28
2^n >= 30
n=5
Subnet mask(last octet) = 11111000 = 248
Subnet mask = 255.255.255.248

3. You have been assigned a Class C network address. Your manager has asked to
create 30 subnets with at least 5 hosts per subnet for the different departments in
your organization. What should the subnet mask be to create 30 subnets.

Solution is in finding no.of subnet bits required.

- Default subnet mask of class C - 255.255.255.0

- Use last octet for subnetting

2^n - 2 >= 28
2^n >= 30
n=5
Subnet mask(last octet) = 11111000 = 248
Subnet mask = 255.255.255.248 (Answer)

4. Your ISP has provided you the following Class B network range 131.107.0.0/24.
Which of the following statement is true regarding this network ? (Choose any two)

a. There are 254 usable hosts per subnet


b. There is one usable network
c. There are 255 usable hosts per subnet
d. There are 254 usable subnets
e. There are 30 usable subnets
f. There are 62 usable hosts per subnet

Answer: A and D
Exercises-2

5. Using the following address and subnet mask 195.106.14.0/24, what is the total
number of networks and the total number of hosts per network.

Solution
- Class C address [ Default subnet mask is 255.255.255.0 ]
- ie: 8 + 8 + 8 + 0
- 8 bits of last octet alone is left for subnetting.
Answer: 1 network with 254 hosts

6. How many usable host addresses are available on a class B, unsubnetted network
?

Answer: 2^16 - 2

7. How many unique class B network addresses are there ?

Answer: 2^14

8. In a class A address where 4 bits have been borrowed for subnetting. How many
bits are left for host addresses.

Answer: 20 bits

9. What is the broadcast address of the second usable subnet in class C where 4 bits
were borrowed.

a. N.N.N.255
b. N.N.N.47 => Answer
c. N.N.N.95
d. N.N.N.63

Solution:
- Class C subnet mask [255.255.255.0]
- 4 bits are borrowed [255.255.255.11110000]
- ie: 255.255.255.240
- Block size = 256 - 240 = 16
- Subnets are:
N.N.N.16
N.N.N.32
N.N.N.48
N.N.N.64
.. .. ..

10. Hosts that reside on a network with the same network ID can communicate
directly with each other.

11. Given a class A address that has been subnetted(8 bits borrowed), what is the
subnet mask ?
Exercises-3

Answer: 255.255.0.0

12. Using a class C address you need 5 subnets with a maximum of 17 hosts on each
of these subnets. which subnet mask would you use ?

Solution:
- Class C address [Default mask : 255.255.255.0]
- 2^n - 2 = 5
- 2^n = 7
- n = 3 [ 1110 0000 ]

Answer: 255.255.255.224

13.

- Find the class to use ?

Class B address is used (172.16.0.0) . Class C cannot be used because we need 57 subnet,
each with approximately 200 hosts, which is not possible with a class C address. (If two
bits of last octet are used as subnet bits, only 6 bits are left for hosts)

- Find the default subnet mask .

255.255.0.0

- Find the no.of subnet bits to be used.

2^n - 2 <= 57
Exercises-4

2^n <= 59
2^n ~ 64
n=6

- 3rd octet = 1111 1100 = 252

- Block Size = 256 - 252 = 4 subnets

- Allocate the Subnet, Host and Broadcast address using block size 4.

Subnet Addr Host IP Range Broadcast Address


--------------- ------------------ -----------------------
172.16.4.0 172.16.4.1 - 7.254 172.16.7.255
172.16.8.0 172.16.8.1 - 11.254 172.16.11.255
172.16.12.0 .. .. .. .. ... ..
.. .. .. .. .. .. .. .. ... ..
172.16.252.0 172.16.252.1 - 255.254 172.16.255.255

14. Given an IP address and mask. 10.48.39.106/21

1. What is the subnet address ?


2. What is the subnet broadcast address?
3. What are the assignable IP addresses in that network/subnet ?
4. What are the valid subnet numbers ?

Answer

1. Find the class used ?

Class A address (10.0.0.0)

2. Find the default subnet mask .

255.0.0.0

3. /21 means 8 bit + 8 bit + 5 bit

255.255.11111000.00000000
255.255.248.0

4. Blocksize = 256 - 248 = 8

5. Allocate Subnets. Start incrementing by 8 until you come to the range the specified
host lives in:

10.48.8.0
10.48.16.0
Exercises-5

10.48.24.0
10.48.32.0 (Answer) [10.48.32.1 - 10.48.39.254] [10.48.39.255]
10.48.40.0

1. What is the subnet address ?

10.48.32.0

2. What is the subnet broadcast address?

10.48.39.255

3. What are the assignable IP addresses in that network/subnet ?

10.48.32.1 - 10.48.39.254

4. What are the valid subnet numbers ?

Any increment of 8.
256/8 = 32 (Total subnets)

You might also like