IP addresses and CIDR notation
Topic: Networking basics
Summary
IPv4 addresses are 32-bit; IPv6 are 128-bit. CIDR (e.g. 192.168.1.0/24) denotes an address and its network prefix length so you can compute the network, broadcast, and host range. Use this when configuring interfaces, routing, or firewall rules that use subnets.
Intent: How-to
Quick answer
- IPv4: four octets (e.g. 192.168.1.10); /24 means the first 24 bits are the network, 8 bits for hosts (254 usable in that subnet).
- CIDR: 192.168.1.0/24 is the network; 192.168.1.255 is broadcast; 192.168.1.1–254 are host addresses; the prefix length is the number of bits that identify the network.
- Use CIDR in routes, firewall rules, and configs (e.g. allow 10.0.0.0/8) so you specify a block of addresses; /32 is a single host.
Steps
-
Read IPv4 address and prefix
An IPv4 address is 32 bits, written as four octets (0–255). CIDR adds /n where n is the prefix length (0–32). The first n bits are the network; the rest are the host part within that network.
-
Compute network and host range
For 192.168.1.0/24: network 192.168.1.0, broadcast 192.168.1.255, usable hosts 192.168.1.1–254. For /25 you get two /24-sized halves; for /32 it is a single host.
-
Use CIDR in config
Routes: 192.168.1.0/24 via gateway. Firewall: allow source 10.0.0.0/8. Interface: address 192.168.1.10/24 so the host knows it is in 192.168.1.0/24.
-
Relate to IPv6
IPv6 addresses are 128 bits, written in hex with colons; CIDR works the same (e.g. 2001:db8::/32). Prefix lengths common in IPv6 are /64 for a subnet and /128 for a single host.
Summary
IP addresses identify hosts; CIDR notation (address/prefix-length) identifies a network and its size. Use this when setting addresses, routes, or firewall rules so you can work with subnets correctly.
Prerequisites
- None; this is a foundation concept.
Steps
Step 1: Read IPv4 address and prefix
An IPv4 address is 32 bits, usually written as four decimal octets (e.g. 192.168.1.10). In CIDR, the prefix length (e.g. /24) is the number of leading bits that define the network; the remaining bits identify the host within that network.
Step 2: Compute network and host range
For 192.168.1.0/24: the network address is 192.168.1.0, the broadcast is 192.168.1.255, and usable host addresses are 192.168.1.1 through 192.168.1.254. For a /25, the same classful “network” is split into two smaller subnets.
Step 3: Use CIDR in config
- Route: e.g. 192.168.1.0/24 via 192.168.0.1.
- Firewall: e.g. allow from 10.0.0.0/8.
- Interface: e.g. 192.168.1.10/24 so the host knows its subnet and mask.
Step 4: Relate to IPv6
IPv6 addresses are 128 bits (hex with colons). CIDR is used the same way: /64 is typically one subnet, /128 is a single host. Notation like 2001:db8::/32 defines an IPv6 prefix.
Verification
- You can write the network and broadcast for a given IPv4 CIDR (e.g. /24, /25) and use CIDR in a sample route or firewall rule.
Troubleshooting
Wrong network after config — Check that the address and prefix match the intended subnet; a wrong /24 can put the host in a different network and break routing.
Too few hosts — A longer prefix (e.g. /28) gives fewer addresses; shorten the prefix (e.g. /23) if you need more hosts in one subnet, or use multiple subnets.