Basics of IP address ,IP-address classes, Subnet mask
1. 8. IP Address
What is an IP Address?
An IP (Internet Protocol) address is a unique identifier assigned to each device connected
to a network that uses the Internet Protocol for communication. This address helps to
identify both the host and the location of the host within the network, allowing data to be sent
and received accurately.
IP Address Structure
IP addresses are typically written in the format of four numbers separated by dots, known
as dotted decimal notation. For example: 1128.11.3.31. Each number in an IP address
represents 8 bits, so an IPv4 address (which is most commonly used) is a 32-bit address
divided into four octets.
IP Address Classes ( Classful Addressing)
IPv4 addresses are divided into five classes (A, B, C, D, and E), primarily based on the
network size they are suited for. Classes A, B, and C are commonly used for hosts, while
classes D and E are reserved for special purposes.
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for
multicast and experimental purposes respectively. The order of bits in the first octet
determines the classes of the IP address.
The class of IP address is used to determine the bits used for network ID and host ID and
the number of total networks and hosts possible in that particular class. Each ISP or network
administrator assigns an IP address to each device that is connected to its network.
2.
Note:
● IP addresses are globally managed by Internet Assigned Numbers
Authority(IANA) and Regional Internet Registries(RIR).
● While finding the total number of host IP addresses, 2 IP addresses are not counted
and are therefore, decreased from the total count because the first IP address of any
network is the network number and whereas the last IP address is reserved for
broadcast IP.
Class A
IP addresses belonging to class A are assigned to the networks that contain a large number of
hosts. The network ID is 8 bits long.The host ID is 24 bits long.
The higher-order bit of the first octet in class A is always set to 0. The remaining 7 bits in the
first octet are used to determine network ID. The 24 bits of host ID are used to determine the
host in any network. The default subnet mask for Class A is 255.x.x.x. Therefore, class A has
a total of:2^24 – 2 = 16,777,214 host ID
IP addresses belonging to class A ranges from 0.0.0.0 – 127.255.255.255.
Supports: 16 million+ hosts per network
Example: Used by big organizations like Google, Microsoft
3.
Class B
IP address belonging to class B is assigned to networks that range from medium-sized to
large-sized networks.
● The network ID is 16 bits long.
● The host ID is 16 bits long.
The higher-order bits of the first octet of IP addresses of class B are always set to 10. The
remaining 14 bits are used to determine the network ID. The 16 bits of host ID are used to
determine the host in any network. The default subnet mask for class B is 255.255.x.x. Class
B has a total of:
● 2^14 = 16384 network address
● 2^16 – 2 = 65534 host address
IP addresses belonging to class B ranges from 128.0.0.0 – 191.255.255.255.
Example: Used by universities and large companies
Supports: 65,000+ hosts per network
4. Class C
IP addresses belonging to class C are assigned to small-sized networks.
● The network ID is 24 bits long.
● The host ID is 8 bits long.
The higher-order bits of the first octet of IP addresses of class C is always set to 110. The
remaining 21 bits are used to determine the network ID. The 8 bits of host ID are used to
determine the host in any network. The default subnet mask for class C is 255.255.255.x.
Class C has a total of:
● 2^21 = 2097152 network address
● 2^8 – 2 = 254 host address
Example: Used for home networks and small businesses
IP addresses belonging to class C range from 192.0.0.0 – 223.255.255.255.
Supports: 254 hosts per network
Class D
IP address belonging to class D is reserved for multi-casting. The higher-order bits of the first
octet of IP addresses belonging to class D is always set to 1110. The remaining bits are for
the address that interested hosts recognize.
Class D does not possess any subnet mask. IP addresses belonging to class D range from
224.0.0.0 – 239.255.255.255.
No Subnetting
5. ● Example: Used in video streaming, IPTV, and online gaming
Class E
IP addresses belonging to class E are reserved for experimental and research purposes. IP
addresses of class E range from 240.0.0.0 – 255.255.255.255. This class doesn’t have any
subnet mask. The higher-order bits of the first octet of class E are always set to 1111.
Range of Special IP Addresses
1. Link-Local Addresses: 169.254.0.0 – 169.254.255.255
○ Assigned automatically when a device fails to obtain an IP from a DHCP
server.
○ Used for local network communication (e.g., direct Ethernet connection).
2. Loopback Addresses: 127.0.0.0 – 127.255.255.255
○ Used for internal testing within a device (self-communication).
○ 127.0.0.1 is the most common loopback address.
3. Default Route (Unspecified Address): 0.0.0.0
○ Represents "any network" or an unspecified address before assignment.
○ Used in routing tables and DHCP configurations.
6. A subnet (subnetwork) is a logically divided portion of a larger network. Subnetting
helps improve network efficiency, security, and address allocation by breaking a large
network into smaller,
What is a Subnet Mask?
A subnet mask determines which part of an IP address is for the network and which
part is for hosts (devices).
It helps divide a large network into smaller subnets to improve efficiency and security.
Understanding Subnet Masks
An IPv4 address has 32 bits, divided into:
● Network portion (Identifies the network)
● Host portion (Identifies devices within the network)
A subnet mask is also 32 bits long and is used to separate these portions.
7. Rules for Network ID
The Network ID identifies a group of devices that share the same network. The rules for
assigning a Network ID are:
1. The Network ID cannot start with 127
○ Reason:The 127.x.x.x range is reserved for loopback addresses, which are
used for internal testing on a device (e.g., 127.0.0.1).
2. All bits in the Network ID cannot be set to 1
○ Reason: If all bits are 1 (255.255.255.255), it represents a broadcast
address, which is used to send data to all devices on the network.
3. All bits in the Network ID cannot be set to 0
○ Reason: If all bits are 0 (0.0.0.0), it refers to the default route, which
means "any network" or "this network."
4. The Network ID must be the same for all hosts in a subnet
○ Reason: Devices in the same network must have the same Network ID so
they can communicate directly without a router.
8. Rules for Host ID
The Host ID uniquely identifies a device within a network. The rules for assigning a Host ID
are:
1. The Host ID cannot be all 0s
○ Reason: If all bits in the Host ID are 0 (192.168.1.0 in
255.255.255.0), it represents the network address, which identifies the
entire subnet.
2. The Host ID cannot be all 1s
○ Reason: If all bits in the Host ID are 1 (192.168.1.255 in
255.255.255.0), it represents the broadcast address, which is used to
send data to all hosts in the network.
3. Each device must have a unique Host ID
○ Reason: If two devices have the same Host ID, IP address conflicts will
occur, causing network communication issues.
9. Example: Class C Network (192.168.1.0/24)
● Network ID: 192.168.1.0
● Usable Host IDs: 192.168.1.1 to 192.168.1.254
● Broadcast Address: 192.168.1.255
127.x.x.x is reserved for loopback testing (not used for networking).
Class D is used for multicast transmissions (not assigned to devices).
Class E is reserved for research and experimental purposes.
10. 1. Subnetting Overview
Subnetting divides a larger IP network into smaller, manageable segments (subnets).
This is useful for organizing network devices logically, improving security, and conserving IP
addresses.
Each subnet functions as an isolated network with its own range of IP addresses, and
this setup allows devices within a subnet to communicate directly while restricting external
access.
Why Subnetting?
● Efficient Use of IP Addresses: Subnetting helps to allocate the appropriate number
of IP addresses for each network segment, preventing waste.
● Improved Network Management: It allows administrators to organize devices
logically, such as by department or geographical location.
● Enhanced Security: Traffic within a subnet can be isolated from other subnets,
protecting internal communications.
● Reduced Broadcast Traffic: Smaller networks reduce the volume of broadcast
traffic, which can improve network performance.
2. Subnet Masks
A subnet mask is used to identify the network and host portions of an IP address. It
essentially "masks" the IP address to distinguish the parts used for network identification
from those used for hosts.
For example:
● Subnet Mask for Class A: 255.0.0.0
● Subnet Mask for Class B: 255.255.0.0
● Subnet Mask for Class C: 255.255.255.0
These default masks can be adjusted to create smaller subnets, allowing us to control the
number of subnets and the number of hosts per subnet.
11. 3. CIDR Notation
3. CIDR Notation
CIDR simplifies subnetting by using a "prefix length" to define the network portion of an IP
address.
Examples:
● 192.168.1.0/24 → First 24 bits for the network, 254 usable hosts.
● 172.16.0.0/16 → First 16 bits for the network, more hosts available.
4. Subnetting Example
To divide 192.168.1.0/24 into four smaller subnets, we use a /26 mask
(255.255.255.192), creating subnets with 62 usable IPs each:
● 192.168.1.0/26 → 192.168.1.1 - 192.168.1.62
● 192.168.1.64/26 → 192.168.1.65 - 192.168.1.126
● 192.168.1.128/26 → 192.168.1.129 - 192.168.1.190
● 192.168.1.192/26 → 192.168.1.193 - 192.168.1.254
5. Key Points
● More network bits (/ higher) → Fewer hosts per subnet.
● Subnet formula:
○ Subnets = 2^subnet_bits
○ Hosts per subnet = 2^host_bits - 2
Using these formulas, you can create customized subnets based on the specific needs of your
network.