IPv4 Addressing & Classes

Nerd Cafe

16,384 (2¹⁴)1. Introduction to IPv4

IPv4 (Internet Protocol version 4) is the fourth version of the Internet Protocol, and it is the most widely used protocol for identifying devices on a network. IPv4 uses a 32-bit address, which is expressed as four octets (8-bit values) separated by dots (.).

Example of an IPv4 Address:

192.168.1.1

Each octet is represented in decimal form and ranges from 0 to 255 (since 8-bit binary numbers range from 00000000 to 11111111 in binary, which equals 0 to 255 in decimal).

2. IPv4 Addressing Format

An IPv4 address consists of two parts:

  1. Network Portion – Identifies the network to which the device belongs.

  2. Host Portion – Identifies a specific device (host) within the network.

The separation between the network and host portions depends on the subnet mask.

3. IPv4 Address Classes

IPv4 addresses are divided into five classes (A, B, C, D, E) based on their first octet. Each class has different network and host allocations.

Class
First Octet Range
Default Subnet Mask
Networks Available
Hosts per Network
Purpose

A

1 - 126

255.0.0.0

128 (2⁷ - 2)

16,777,214 (2²⁴ - 2)

Large networks (e.g., ISPs, big enterprises)

B

128 - 191

255.255.0.0

16,384 (2¹⁴)

65,534 (2¹⁶ - 2)

Medium-sized businesses and organizations

C

192 - 223

255.255.255.0

2,097,152 (2²¹)

254 (2⁸ - 2)

Small businesses and local networks

D

224 - 239

N/A

N/A

N/A

Multicast groups (not used for host addressing)

E

240 - 255

N/A

N/A

N/A

Experimental use (Reserved by IETF)

Note:

  • The first octet range 127 is reserved for loopback addresses (e.g., 127.0.0.1 is used for local testing).

  • The subnet mask helps define the boundary between the network and host portions.

4. Binary Representation of IPv4 Addresses

Each octet in an IPv4 address is an 8-bit binary number.

Example: Convert 192.168.1.1 into Binary:

  1. Convert each octet into an 8-bit binary format:

    • 19211000000

    • 16810101000

    • 100000001

    • 100000001

Thus,

192.168.1.1  =  11000000.10101000.00000001.00000001 (Binary)

This binary format is useful for subnetting, CIDR notation, and routing decisions.

5. Private vs Public IPv4 Addresses

IPv4 addresses are categorized into public and private ranges.

Private IPv4 Address Ranges (RFC 1918)

Class
Private IP Range
CIDR Notation
Total IPs

A

10.0.0.0 – 10.255.255.255

10.0.0.0/8

16,777,216

B

172.16.0.0 – 172.31.255.255

172.16.0.0/12

1,048,576

C

192.168.0.0 – 192.168.255.255

192.168.0.0/16

65,536

  • Private IPs are used inside organizations and home networks and are not routable on the public internet.

  • Public IPs are assigned by ISPs and used to connect to the internet.

6. IPv4 Addressing Practical Lab

Let’s perform a practical IPv4 addressing scenario.

Scenario:

You are given the network 192.168.10.0/24. You need to assign IPv4 addresses to 5 devices.

Topology

Steps:

  1. Identify Network Address: 192.168.10.0

  2. Identify Subnet Mask: 255.255.255.0

  3. Find Usable Host IP Range: 192.168.10.1 – 192.168.10.254

  4. Assign IPs to Devices:

    • Router: 192.168.10.1

    • PC1: 192.168.10.10

    • PC2: 192.168.10.20

    • Server: 192.168.10.30

    • Printer: 192.168.10.40

  5. Broadcast Address: 192.168.10.255

  6. Validation: Use the ping command to test connectivity.

R1 Configuration

Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.10.1 255.255.255.0
Router(config-if)#no shut

PC1 Configuration

PC1> ip 192.168.10.10/24 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1

PC1> show ip

NAME        : PC1[1]
IP/MASK     : 192.168.10.10/24
GATEWAY     : 192.168.10.1
DNS         :
MAC         : 00:50:79:66:68:00
LPORT       : 20012
RHOST:PORT  : 127.0.0.1:20013
MTU         : 1500

PC1> save
Saving startup configuration to startup.vpc
.  done

PC1>

PC2 Configuration

PC2> ip 192.168.10.20/24 192.168.10.1
Checking for duplicate address...
PC2 : 192.168.10.20 255.255.255.0 gateway 192.168.10.1

PC2> show ip

NAME        : PC2[1]
IP/MASK     : 192.168.10.20/24
GATEWAY     : 192.168.10.1
DNS         :
MAC         : 00:50:79:66:68:01
LPORT       : 20014
RHOST:PORT  : 127.0.0.1:20015
MTU         : 1500

PC2> save
Saving startup configuration to startup.vpc
.  done

PC2>

Server Configiration

Server> ip 192.168.10.30/24 192.168.10.1
Checking for duplicate address...
Server : 192.168.10.30 255.255.255.0 gateway 192.168.10.1

Server> show ip

NAME        : Server[1]
IP/MASK     : 192.168.10.30/24
GATEWAY     : 192.168.10.1
DNS         :
MAC         : 00:50:79:66:68:02
LPORT       : 20016
RHOST:PORT  : 127.0.0.1:20017
MTU         : 1500

Server> save
Saving startup configuration to startup.vpc
.  done

Server>

Printer Configuration

Printer> ip 192.168.10.40/24 192.168.10.1
Checking for duplicate address...
Printer : 192.168.10.40 255.255.255.0 gateway 192.168.10.1

Printer> show ip

NAME        : Printer[1]
IP/MASK     : 192.168.10.40/24
GATEWAY     : 192.168.10.1
DNS         :
MAC         : 00:50:79:66:68:03
LPORT       : 20018
RHOST:PORT  : 127.0.0.1:20019
MTU         : 1500

Printer> save
Saving startup configuration to startup.vpc
.  done

Printer>

Connectivity Tests

PC1> ping 192.168.10.1

84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=50.985 ms
84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=13.339 ms
^C
PC1> ping 192.168.10.20

84 bytes from 192.168.10.20 icmp_seq=1 ttl=64 time=0.599 ms
84 bytes from 192.168.10.20 icmp_seq=2 ttl=64 time=0.665 ms
^C
PC1> ping 192.168.10.30

84 bytes from 192.168.10.30 icmp_seq=1 ttl=64 time=0.521 ms
84 bytes from 192.168.10.30 icmp_seq=2 ttl=64 time=0.531 ms
^C
PC1> ping 192.168.10.40

84 bytes from 192.168.10.40 icmp_seq=1 ttl=64 time=0.668 ms
84 bytes from 192.168.10.40 icmp_seq=2 ttl=64 time=0.742 ms
^C
PC1>

7. Configuring IPv4 Address in Windows/Linux

Windows:

  • Open Command Prompt (cmd).

  • Type:

C:\Users\nerd-cafe>ipconfig

Windows IP Configuration

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::298e:fec6:a21f:8a40%38
   IPv4 Address. . . . . . . . . . . : 192.168.1.244
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

C:\Users\nerd-cafe>

This shows current IP settings.

  • To set an IPv4 address manually:

netsh interface ip set address "Ethernet" static 192.168.10.10 255.255.255.0 192.168.10.1
  • 192.168.10.10 → IP Address

  • 255.255.255.0 → Subnet Mask

  • 192.168.10.1 → Default Gateway

Linux:

  1. Open Terminal.

  2. Check current IP:

ifconfig

or

ip addr show
  • Assign an IPv4 address manually:

sudo ifconfig eth0 192.168.10.10 netmask 255.255.255.0

or

sudo ip addr add 192.168.10.10/24 dev eth0

8. Summary

  • IPv4 uses a 32-bit address and is represented in decimal form.

  • It is divided into five classes (A, B, C, D, E).

  • Private IPv4 addresses are used for internal networks.

  • Subnet masks determine the network/host boundary.

  • IPv4 can be configured using Windows (netsh) or Linux (ifconfig/ip).

  • Practical IPv4 addressing is essential for networking professionals.

Keywords

IPv4 addressing, IP classes, subnet mask, network portion, host portion, Class A, Class B, Class C, Class D, Class E, private IP, public IP, CIDR notation, binary representation, loopback address, default gateway, IP configuration, DHCP, static IP, IP routing, نتورک پلاس

Last updated