Find Network Address for /24
Beginner IdentifyQuestion
Given the IP address 192.168.1.45 with a /24 prefix length, identify the network address, broadcast address, first usable host, last usable host, and total number of usable hosts.
Given
{
"ip": "192.168.1.45",
"prefix": 24
}
Answer
{
"network": "192.168.1.0",
"broadcast": "192.168.1.255",
"first_host": "192.168.1.1",
"last_host": "192.168.1.254",
"host_count": 254
}
Try to solve it first, then click Reveal Answer
Step-by-Step Explanation
Step 1: Convert the prefix length to a subnet mask
A /24 prefix means the first 24 bits are the network portion:
Binary subnet mask: 11111111.11111111.11111111.00000000
Dotted decimal: 255 .255 .255 .0
Step 2: Apply the subnet mask to find the network address
Perform a bitwise AND between the IP address and the subnet mask:
IP address: 192.168. 1. 45 → 11000000.10101000.00000001.00101101
Subnet mask: 255.255.255. 0 → 11111111.11111111.11111111.00000000
AND ─────────────────────────────────────
Network: 192.168. 1. 0 → 11000000.10101000.00000001.00000000
Step 3: Find the broadcast address
Set all host bits (the last 8 bits) to 1:
Network: 192.168.1.0 → 11000000.10101000.00000001.00000000
Host bits all 1: → 11000000.10101000.00000001.11111111
Broadcast: 192.168.1.255
Step 4: Calculate the host range
- First host: network address + 1 = 192.168.1.1
- Last host: broadcast address − 1 = 192.168.1.254
- Usable hosts: 2^(32−24) − 2 = 2^8 − 2 = 256 − 2 = 254
The −2 accounts for the network address (192.168.1.0) and broadcast address (192.168.1.255), which cannot be assigned to hosts.
Summary
| Field | Value |
|---|---|
| Network | 192.168.1.0 |
| Broadcast | 192.168.1.255 |
| First host | 192.168.1.1 |
| Last host | 192.168.1.254 |
| Usable hosts | 254 |