Ip_addressing
Chapter 3: IP Addressing (IPv4 & IPv6)
Section titled “Chapter 3: IP Addressing (IPv4 & IPv6)”3.1 IPv4 Address Structure
Section titled “3.1 IPv4 Address Structure”An IPv4 address is a 32-bit number divided into 4 octets (8 bits each).
IPv4 Address Structure+------------------------------------------------------------------+
Example: 192.168.1.100
+------------------------------------------------------------------+| || Binary: 11000000 . 10101000 . 00000001 . 01100100 || | | | | || Octet 1 Octet 2 Octet 3 Octet 4 || 192 168 1 100 || || Total bits: 32 bits || Total possible addresses: 2^32 = 4,294,967,296 || |+------------------------------------------------------------------+
IPv4 Dotted Decimal:+------------------------------------------------------------------+| || Each octet: 0-255 (8 bits = 256 values) || || Range: 0.0.0.0 to 255.255.255.255 || |+------------------------------------------------------------------+3.2 IPv4 Address Classes
Section titled “3.2 IPv4 Address Classes” IPv4 Address Classes+------------------------------------------------------------------+
Class | First Octet Range | Default Subnet Mask | Networks | Hosts/Network------|---------------------|--------------------|----------|-------------- A | 1 - 126 | 255.0.0.0 (/8) | 126 | 16,777,214 B | 128 - 191 | 255.255.0.0 (/16) | 16,384 | 65,534 C | 192 - 223 | 255.255.255.0 (/24)|2,097,152| 254 D | 224 - 239 | None (Multicast) | - | - E | 240 - 255 | None (Reserved) | - | -
+------------------------------------------------------------------+
Special Addresses:+------------------------------------------------------------------+| 0.0.0.0 | This network (RFC 1122) || 127.0.0.1 | Loopback address || 255.255.255.255 | Limited broadcast || x.x.x.0 | Network address (all host bits = 0) || x.x.x.255 | Broadcast address (all host bits = 1) |+------------------------------------------------------------------+3.3 Private IP Addresses (RFC 1918)
Section titled “3.3 Private IP Addresses (RFC 1918)”These addresses are not routable on the Internet and are used internally.
Private IP Ranges+------------------------------------------------------------------+
Class | Network Address | Range | CIDR------|-----------------------|----------------------------|--------- A | 10.0.0.0 | 10.0.0.0 - 10.255.255.255 | /8 B | 172.16.0.0 | 172.16.0.0 - 172.31.255.255|/12 C | 192.168.0.0 | 192.168.0.0 - 192.168.255.255|/16
+------------------------------------------------------------------+
Why Private Addresses?+------------------------------------------------------------------+| - IPv4 address exhaustion || - Security (not directly accessible from internet) || - Reuse in different networks || - Requires NAT to access internet |+------------------------------------------------------------------+
Example Network Topology:+------------------------------------------------------------------+
Internet | | [Router/NAT] | +-------------+-------------+ | | | LAN 1 LAN 2 LAN 3 10.0.1.x 10.0.2.x 10.0.3.x Private Private Private
+------------------------------------------------------------------+3.4 Subnet Masks
Section titled “3.4 Subnet Masks”A subnet mask determines which portion of an IP address is the network and which is the host.
Subnet Mask+------------------------------------------------------------------+
Example: 192.168.1.100/24
+------------------------------------------------------------------+| || IP Address (binary): || 11000000 . 10101000 . 00000001 . 01100100 || || Subnet Mask (binary): || 11111111 . 11111111 . 11111111 . 00000000 || || Subnet Mask (decimal): || 255 . 255 . 255 . 0 || || /24 = 24 ones in the network portion || |+------------------------------------------------------------------+
Common Subnet Masks:+------------------------------------------------------------------+
CIDR | Dotted Decimal | Total IPs | Usable IPs | Powers of 2------|--------------------|------------|------------|-------------/32 | 255.255.255.255 | 1 | 0 | -/31 | 255.255.255.254 | 2 | 0* | 2/30 | 255.255.255.252 | 4 | 2 | 4/29 | 255.255.255.248 | 8 | 6 | 8/28 | 255.255.255.240 | 16 | 14 | 16/27 | 255.255.255.224 | 32 | 30 | 32/26 | 255.255.255.192 | 64 | 62 | 64/25 | 255.255.255.128 | 128 | 126 | 128/24 | 255.255.255.0 | 256 | 254 | 256/23 | 255.255.254.0 | 512 | 510 | 512/22 | 255.255.252.0 | 1,024 | 1,022 | 1,024/21 | 255.255.248.0 | 2,048 | 2,046 | 2,048/20 | 255.255.240.0 | 4,096 | 4,094 | 4,096
* /31 is for point-to-point links (RFC 3021)* Always subtract 2 for network and broadcast addresses
+------------------------------------------------------------------+3.5 IPv6 Address Structure
Section titled “3.5 IPv6 Address Structure”IPv6 uses 128 bits (16 bytes) instead of 32 bits.
IPv6 Address Structure+------------------------------------------------------------------+
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
+------------------------------------------------------------------+| || Full form: || 2001:0db8:85a3:0000:0000:8a2e:0370:7334 || || 8 groups of 16 bits each = 128 bits total || |+------------------------------------------------------------------+
IPv6 Address Types:+------------------------------------------------------------------+| || Unicast | Single interface address || +---------|--------------------------------------------------|| | Global Unicast | Public address (2000::/3) || | Link-Local | FE80::/10 (auto-configured) || | Unique Local | FC00::/7 (private) || | Loopback | ::1 || +---------|--------------------------------------------------|| || Multicast | FF00::/8 (one-to-many) || || Anycast | One-to-nearest (from the group) || |+------------------------------------------------------------------+
IPv6 Address Notation Shortcuts:+------------------------------------------------------------------+
Rule 1: Leading zeros in each hextet can be removed
2001:0db8:85a3:0000:0000:8a2e:0370:73342001: db8:85a3: 0: 0: 8a2e: 370:7334
Rule 2: One consecutive group of zeros can be replaced with ::
2001:db8:85a3::8a2e:0370:7334
Invalid: 2001::85a3::7334 (ambiguous!)
+------------------------------------------------------------------+
IPv6 Prefix Lengths:+------------------------------------------------------------------+
/64 | Subnet (typical for LAN)/48 | Site prefix/32 | Regional registry prefix/128 | Single interface
+------------------------------------------------------------------+3.6 Special IPv6 Addresses
Section titled “3.6 Special IPv6 Addresses” Special IPv6 Addresses+------------------------------------------------------------------+
Address | Full Form | Description----------------------|--------------------------------|------------------:: (unspecified) | 0000:0000:0000:0000: | No address | 0000:0000:0000:0000 |----------------------|--------------------------------|------------------::1 (loopback) | 0000:0000:0000:0000: | Localhost | 0000:0000:0000:0001 |----------------------|--------------------------------|------------------2001:db8::/32 | Documentation prefix | Not routable----------------------|--------------------------------|------------------fe80::/10 | Link-Local | Auto-configured----------------------|--------------------------------|------------------fc00::/7 | Unique Local Address | Private----------------------|--------------------------------|------------------ff00::/8 | Multicast | Multi-way----------------------|--------------------------------|------------------
+------------------------------------------------------------------+
IPv6 Link-Local Address:+------------------------------------------------------------------+
Automatically generated from MAC address (EUI-64):
MAC: 00:1a:2b:3c:4d:5e | | Insert FF:FE in middle vEUI-64: 001a:2bff:fe3c:4d5e | | Toggle 7th bit vModified: 021a:2bff:fe3c:4d5e | | Add prefix vfe80::21a:2bff:fe3c:4d5e
+------------------------------------------------------------------+3.7 IPv4 vs IPv6 Comparison
Section titled “3.7 IPv4 vs IPv6 Comparison” IPv4 vs IPv6 Comparison+------------------------------------------------------------------+
Feature | IPv4 | IPv6---------------------|-------------------|-------------------Address Length | 32 bits | 128 bitsAddress Space | ~4.3 billion | ~340 undecillionNotation | Dotted decimal | Hex groupsSubnet Mask | Required | Prefix lengthARP | Used | NDP (Neighbor Discovery)Fragmentation | Router and host | Host onlyHeader Size | 20-60 bytes | 40 bytes (fixed)Security | Optional (IPsec)| Built-in IPsecConfiguration | Manual or DHCP | Auto-config (SLAAC)NAT | Required | Not neededBroadcast | Yes | No (multicast)Quality of Service | DSCP field | Traffic class field
+------------------------------------------------------------------+
IPv4 Exhaustion Timeline:+------------------------------------------------------------------+
1981 - IPv4 developed1983 - ARPANET converts to TCP/IP1992 -ripe.net established (regional registries)2011 - IANA exhaustion (last /8 blocks allocated)2012 - RIPE NCC exhaustion2015 - ARIN exhaustion (North America)2019 - RIPE NCC runs out of free pools2020+ - Increasing NAT usage, IPv6 adoption
+------------------------------------------------------------------+3.8 Network Commands
Section titled “3.8 Network Commands”Checking IP Address (Linux)
Section titled “Checking IP Address (Linux)”# Modern command (ip)ip addr showip addr show eth0
# Show only IPv4 addressesip -4 addr show
# Show only IPv6 addressesip -6 addr show
# Legacy command (ifconfig)ifconfigifconfig eth0
# Check specific interfaceip link showip link set eth0 upip link set eth0 downRouting Table
Section titled “Routing Table”# View routing tableip route showip route
# Legacyroute -nnetstat -rn
# IPv6 routesip -6 route show
# Get route to specific destinationip route get 8.8.8.8ARP Table
Section titled “ARP Table”# View ARP cacheip neigh showarp -a
# Add static ARP entryip neigh add 192.168.1.1 lladdr aa:bb:cc:dd:ee:ff dev eth0
# Delete ARP entryip neigh del 192.168.1.1 dev eth0Summary
Section titled “Summary”In this chapter, you learned:
- ✅ IPv4 address structure (32-bit, 4 octets)
- ✅ IPv4 address classes (A, B, C, D, E)
- ✅ Private IP addresses (RFC 1918)
- ✅ Subnet masks and CIDR notation
- ✅ IPv6 address structure (128-bit)
- ✅ IPv6 address types and special addresses
- ✅ IPv4 vs IPv6 comparison
- ✅ Linux network commands
Next Chapter
Section titled “Next Chapter”Chapter 4: Subnetting Fundamentals
Last Updated: February 2026