Calculating Host/Network Portions – Detailed Guide
✅ IP Address Structure
An IPv4 address is a 32-bit numeric address, divided into 4 octets, each consisting of 8 bits.
🔸 Example (Decimal & Binary):
Decimal:192.168.10.5
Binary:11000000.10101000.00001010.00000101
✅ Network and Host Portions
An IPv4 address has two main parts:
- Network Portion: Identifies the network.
- Host Portion: Identifies individual devices.
✅ IP Classes & Default Masks:
Class | Address Range | Default Mask | Network/Host Portions |
---|---|---|---|
A | 0.0.0.0 – 127.255.255.255 | 255.0.0.0 (/8) | N.H.H.H |
B | 128.0.0.0 – 191.255.255.255 | 255.255.0.0 (/16) | N.N.H.H |
C | 192.0.0.0 – 223.255.255.255 | 255.255.255.0 (/24) | N.N.N.H |
✅ Subnet Masks and CIDR Notation
A subnet mask separates network and host parts explicitly.
Example: 192.168.10.5/24
means 24 bits for network and 8 bits for hosts.
✅ Calculating Network Portion
Perform a bitwise AND operation between the IP address and subnet mask:
IP:11000000.10101000.00001010.00000101
(192.168.10.5) Mask:11111111.11111111.11111111.00000000
(255.255.255.0) ------------------------------------------------ (AND) Net:11000000.10101000.00001010.00000000
(192.168.10.0)
Network Address: 192.168.10.0
✅ Calculating Host Portion
The number of usable hosts per subnet is calculated by:
Hosts per subnet = (2host bits) – 2
Example: A /24
subnet has 8 host bits:
Hosts = (28) – 2 = 254 usable IPs
✅ Network and Broadcast Addresses
- Network Address: First IP (all host bits = 0).
- Broadcast Address: Last IP (all host bits = 1).
Example:
- Subnet:
192.168.10.0/24
- Usable IPs:
192.168.10.1 – 192.168.10.254
- Broadcast:
192.168.10.255
✅ Subnetting (Bits Borrowing)
Subnetting involves borrowing host bits for subnet creation:
Example: Divide 192.168.20.0/24
into 4 subnets:
Borrowed Bits | Subnets Created | Hosts per Subnet | Subnet Mask | CIDR |
---|---|---|---|---|
2 bits | 4 | 62 | 255.255.255.192 | /26 |
✅ Practical Example Scenario
Given IP: 172.16.50.123/20
. Find network, broadcast, and host range.
- Subnet mask:
255.255.240.0
- Block size: 256 – 240 = 16
- 50 belongs to range: 48–63
Results:
- Network:
172.16.48.0
- Broadcast:
172.16.63.255
- Usable IP range:
172.16.48.1 – 172.16.63.254
✅ Common Mistakes
- Miscalculating borrowed bits.
- Forgetting network and broadcast addresses.
- Confusing subnet mask with wildcard mask.
✅ Tools and Commands
- Subnet Calculators: subnet-calculator.com
- Windows:
ipconfig /all
- Linux/macOS:
ifconfig
orip addr show
📗 Summary Table
Item | Calculation/Definition |
---|---|
Network Address | IP AND subnet mask |
Broadcast Address | Network address + host bits = 1 |
Usable Host Range | Network +1 to Broadcast -1 |
Hosts per subnet | (2host bits) - 2 |