IPv4 Addressing
Nerd Cafe
What is IPv4?
IPv4 (Internet Protocol version 4) is the fourth version of the Internet Protocol (IP). It uses a 32-bit address format, typically represented as four decimal numbers separated by dots (e.g., 192.168.1.1).
Each IP address has two main parts:
Network portion
Host portion
Step 1: Understand IP Classes (Classful Addressing)
A
0.0.0.0
127.255.255.255
255.0.0.0
Large networks
B
128.0.0.0
191.255.255.255
255.255.0.0
Medium networks
C
192.0.0.0
223.255.255.255
255.255.255.0
Small networks
D
224.0.0.0
239.255.255.255
N/A (Multicast)
Multicast
E
240.0.0.0
255.255.255.255
N/A (Reserved)
Reserved
Step 2: Practical Example
Let’s take this IP address as an example: 192.168.10.17/28
Find the Class:
Starts with
192⇒ Class CDefault mask of Class C =
255.255.255.0
Classful or Classless?
/28is a custom prefix ⇒ This is classless addressing (CIDR - Classless Inter-Domain Routing)
Step 3: Convert Prefix /28 to Subnet Mask
/28 to Subnet Mask/28means 28 bits are for the network ⇒ Subnet mask is:
In decimal ⇒ 255.255.255.240
Step 4: Calculate the Network Address
Convert IP and subnet mask to binary:
IP:
192.168.10.17→11000000.10101000.00001010.00010001Subnet mask:
255.255.255.240→11111111.11111111.11111111.11110000
Perform bitwise AND:
Network Address = 192.168.10.16
Step 5: Calculate Broadcast Address
Invert the subnet mask:
Add this to the network address:
Broadcast Address = 192.168.10.31
Step 6: Find First and Last Host
First Host = Network Address + 1 =
192.168.10.17Last Host = Broadcast Address - 1 =
192.168.10.30
Step 7: Total Number of Hosts
Formula:
2^(32 - subnet_prefix) - 2⇒
2^(32 - 28) - 2 = 2^4 - 2 = 14
Total usable hosts = 14
Summary
IP Address
192.168.10.17/28
Class
C
Subnet Mask
255.255.255.240
Network Address
192.168.10.16
Broadcast Address
192.168.10.31
First Host
192.168.10.17
Last Host
192.168.10.30
Total Hosts
14
Classful?
❌ Classless
Step 8: Python Code for an IP Calculator
Here’s a simple Python tool using the ipaddress module:
Output
Keywords
IPv4 addressing, subnet mask, IP calculator, network address, broadcast address, IP class, classful addressing, classless addressing, CIDR, prefix length, total hosts, first host, last host, IP range, IPv4 classes, netmask, private IP, public IP, IP subnetting, IP analysis, nerd cafe
Last updated