| Lesson 7 | IP address Conventions |
| Objective | What is the Structure of an IP Address? |
This lesson modernizes IP addressing concepts for today’s Linux and hybrid cloud environments. We replace legacy classful rules with CIDR (Classless Inter-Domain Routing), clarify how prefix lengths (e.g., /24, /64) actually work, and align examples with current best practices (e.g., private ranges, link-local, loopback, and IPv6 conventions).
203.0.113.7). A prefix length or netmask identifies the network portion (e.g., 203.0.113.7/24 ⇢ mask 255.255.255.0).2001:db8:85a3:0:0:8a2e:370:7334). Leading zeros can be omitted and one contiguous run of zeros can be replaced by :: (e.g., 2001:db8:85a3::8a2e:370:7334).
Instead of fixed classes, CIDR uses a prefix length to define how many leading bits compose the network. The remainder belong to hosts (or subnets if you further partition). For example, 10.20.30.40/23 means the first 23 bits are the network; the last 9 bits vary per host.
# Convert between dotted masks and prefix lengths
# 255.255.255.0 → /24
# 255.255.254.0 → /23
# 255.255.252.0 → /22
# Linux quick checks
ip addr show # list IPv4/IPv6 addresses, prefixes, MACs
ip route show # view routes and connected prefixes
192.0.2.0/24 ⇢ network 192.0.2.0, broadcast 192.0.2.255. (Directed broadcast is often disabled by default on routers for security.)127.0.0.0/8 is loopback; 127.0.0.1 is the common host-local address.0.0.0.0 means “this host, unspecified address” (e.g., servers bind to all interfaces). It is not “the first configured interface.”10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.169.254.0.0/16 (APIPA/zeroconf); used when no DHCP address is obtained.100.64.0.0/10 for carrier-grade NAT.224.0.0.0/4 (no broadcast in IPv6; see below)./ notation (e.g., /64 is standard for most LAN segments).ff02::1 all-nodes; ff02::2 all-routers).:: (unspecified), ::1 (loopback), fe80::/10 (link-local), fc00::/7 (ULA, private-like), 2000::/3 (global-unicast).
Subnetting divides a larger prefix into smaller ones. With 192.168.50.0/24, splitting into four equal subnets yields /26 blocks:
192.168.50.0/26 → usable hosts .1–.62, broadcast .63
192.168.50.64/26 → usable hosts .65–.126, broadcast .127
192.168.50.128/26 → usable hosts .129–.190, broadcast .191
192.168.50.192/26 → usable hosts .193–.254, broadcast .255
Most IPv6 LANs use /64. Hosts typically auto-configure their Interface ID (the last 64 bits) using SLAAC. Routers advertise the network prefix with RA (Router Advertisements); hosts generate addresses like 2001:db8:1234:abcd::a1b2.
# Linux IPv6 examples
ip -6 addr add 2001:db8:1234:abcd::10/64 dev eth0
ip -6 route add default via fe80::1 dev eth0
A netmask (IPv4) or prefix length (IPv4/IPv6) specifies how many leading bits identify the network. VLSM (Variable Length Subnet Masking) lets you allocate different-sized subnets from the same aggregate, improving address efficiency.
# Quick mask ↔ prefix references
/30 = 255.255.255.252 (2 usable IPv4 hosts; point-to-point)
/29 = 255.255.255.248 (6 usable)
/28 = 255.255.255.240 (14 usable)
/24 = 255.255.255.0 (254 usable)
# Show all interfaces with addresses (IPv4/IPv6)
ip addr show
# Add a temporary IPv4 address to an interface
sudo ip addr add 10.0.5.10/23 dev eth0
# Add a static route
sudo ip route add 10.42.0.0/16 via 10.0.5.1 dev eth0
# Verify connectivity and path
ping -c 4 8.8.8.8
traceroute 8.8.8.8 # or: tracepath 8.8.8.8
# Display routing tables
ip route show
ip -6 route show
0.0.0.0 to unspecified address, not “first configured interface.”127.0.0.1.