Supernetting only works when the networks are contiguous and aligned on the summary boundary. 192.168.0.0/24 and 192.168.1.0/24 can be summarized as 192.168.0.0/23, but 192.168.1.0/24 and 192.168.2.0/24 cannot be cleanly summarized (they would require 192.168.0.0/22, which also includes 192.168.0.0/24 and 192.168.3.0/24).
RFC 1918 defines three ranges of private IPv4 addresses that are not routable on the public Internet:
Range CIDR Block Size Class 10.0.0.0 - 10.255.255.255 10.0.0.0/8 16,777,216 addresses A 172.16.0.0 - 172.31.255.255 172.16.0.0/12 1,048,576 addresses B 192.168.0.0 - 192.168.255.255 192.168.0.0/16 65,536 addresses C
These addresses are used for internal networks. Traffic from private addresses must pass through a NAT device (or a proxy) to reach the public Internet. Multiple organizations can use the same Private address ranges simultaneously because the addresses are not globally unique.
10.0.0.0/8: Use for large organizations or when you need many subnets. Provides 16 million addresses, more than enough for most internal networks.172.16.0.0/12: Rarely used because it is awkward to work with (the boundary falls in the middle of the second octet).192.168.0.0/16: The most commonly used range for home and small office networks. Limited to 256 /24 subnets.ISPs with more customers than public IPv4 addresses use Carrier-Grade NAT (CGNAT) to share a pool of Public IPs among many customers. This is called “NAT444” because NAT occurs three times: customer NAT (private to ISP private), ISP CGNAT (ISP private to public), and destination NAT (public to Destination private).
CGNAT introduces problems for customers who need inbound connections (peer-to-peer, hosting, IoT Devices). These customers must request a public IP address from their ISP.
NAT allows multiple hosts with private IP addresses to share one or more public IP addresses. NAT Operates by rewriting the source IP address (and the source port) of outgoing packets and Maintaining a translation table to map return traffic.
SNAT (Source NAT): Rewrites the source IP address of outgoing packets. This is the most common Form of NAT, used by home routers and corporate firewalls. The internal host 192.168.1.100 sends a Packet to 203.0.113.50; the NAT device rewrites the source to its public IP 203.0.113.1 and records The mapping.
DNAT (Destination NAT): Rewrites the destination IP address of incoming packets. Used for port Forwarding. External traffic to 203.0.113.1:80 is forwarded to 192.168.1.10:80.
PAT (Port Address Translation): Also called “NAT overload.” Multiple internal hosts share a Single public IP by using different source ports. The NAT device maintains a table mapping (internal IP, internal port) to (public IP, public port).
Static NAT: A fixed, one-to-one mapping between a private IP and a public IP. Used for servers That need a consistent public IP address.
Double NAT: NAT applied twice (e.g., ISP CGNAT + customer router NAT). Causes issues with Inbound connections, peer-to-peer protocols, and some games.
Internal NAT External Destination
192.168.1.100:54321 -> 203.0.113.1:40001 -> 93.184.216.34:80
192.168.1.101:54322 -> 203.0.113.1:40002 -> 93.184.216.34:80
192.168.1.102:54323 -> 203.0.113.1:40003 -> 93.184.216.34:443
# Enable NAT (masquerade) for outbound traffic on eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# DNAT: Forward port 80 to internal server
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.10:80
# SNAT with specific source address
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 203.0.113.1
nft add rule nat postrouting oif eth0 masquerade
nft add rule nat prerouting iif eth0 tcp dport 80 dnat to 192.168.1.10:80
Breaks end-to-end connectivity. Incoming connections cannot reach internal hosts unless explicitly forwarded. This breaks peer-to-peer protocols (BitTorrent, WebRTC, SIP).Breaks protocols that embed IP addresses in the payload. FTP active mode, SIP, and IPsec (without NAT traversal) fail through NAT because the payload contains IP addresses that are not rewritten. ALGs (Application Layer Gateways) attempt to fix this but are often buggy.Stateful. NAT devices maintain per-connection state. High connection rates exhaust NAT tables, causing new connections to fail. The NAT table size is a hard limit on concurrent connections.Port exhaustion. A single public IP has approximately 65,536 ports. With many internal hosts making many connections, ports can be exhausted. The practical limit is around 50,000-60,000 concurrent connections per public IP.Hides the real source. Logs show the NAT device’s IP, not the actual internal host. This complicates auditing and security analysis.ALGs (Application Layer Gateways). Some NAT devices implement protocol-specific helpers (FTP ALG, SIP ALG) that modify application-layer data to work around NAT. These ALGs are often buggy and cause subtle interoperability issues. Many experienced network engineers disable ALGs and use application-level workarounds instead.DHCP automates IP address assignment on networks. Without DHCP, every host would need manual IP Configuration. RFC 2131 defines DHCP. DHCP operates over UDP ports 67 (server) and 68 (client).
DHCP uses four messages to assign an address:
Discover (client to server, broadcast): Client broadcasts DHCPDISCOVER to 255.255.255.255 on UDP port 67, seeking available DHCP servers. The source IP is 0.0.0.0 (unconfigured).Offer (server to server, broadcast/unicast): DHCP server responds with DHCPOFFER containing an offered IP address, subnet mask, lease duration, and other options (gateway, DNS servers). The server may broadcast or unicast depending on the client’s capabilities.Request (client to server, broadcast): Client broadcasts DHCPREQUEST to accept the offer. If multiple servers offered addresses, this implicitly declines the others.Acknowledge (server to client, broadcast/unicast): Server sends DHCPACK confirming the lease. The client is now configured.sequenceDiagram
participant C as Client
participant S as DHCP Server
C->>S: DHCPDISCOVER (broadcast, UDP 67)
S->>C: DHCPOFFER (IP, mask, gateway, DNS, lease)
C->>S: DHCPREQUEST (broadcast, accepts offer)
S->>C: DHCPACK (confirms lease) Lease time: Configurable by the server, 8-24 hours. Shorter leases are better for dynamic environments (e.g., coffee shop Wi-Fi). Longer leases reduce DHCP traffic but delay address reclamation.T1 timer (50% of lease): Client attempts to renew the lease with the original server via DHCPREQUEST (unicast). If the server agrees, the lease is renewed with the original or new lease duration.T2 timer (87.5% of lease): If renewal fails, client broadcasts DHCPREQUEST to any DHCP server. Any server that can honor the request responds with DHCPACK.Lease expiration (100%): Client must stop using the address and begin the DORA process from scratch. The client should also send a DHCPRELEASE when it shuts down cleanly, but this is not guaranteed.DHCP clients broadcast DHCPDISCOVER, which does not cross router boundaries. On networks with Multiple subnets, a DHCP relay agent (RFC 1542) forwards DHCP broadcasts to a DHCP server on Another subnet. The relay agent adds the giaddr (gateway IP address) field to identify the subnet From which the request originated, allowing the DHCP server to offer an address from the correct Pool.
# Linux dhcpd relay agent
dhcrelay -i eth0 192.168.1.1
# isc-dhcp-relay (Debian/Ubuntu)
apt install isc-dhcp-relay
# Configure in /etc/default/isc-dhcp-relay
DHCP options carry configuration parameters beyond the IP address:
Option Code Name Example 1 Subnet Mask 255.255.255.0 3 Router (Default Gateway) 192.168.1.1 6 DNS Server 8.8.8.8, 8.8.4.4 12 Hostname client-01 15 Domain Name example.com 42 NTP Server time.google.com 51 Lease Time 86400 (seconds) 53 DHCP Message Type 1 (Discover), 2 (Offer), etc. 60 Vendor Class Identifier PXEClient for network boot 67 TFTP Server Name 192.168.1.50 81 Client FQDN client01.example.com 119 Domain Search List example.com, corp.example.com 252 WPAD URL http://proxy.example.com/wpad.dat
# ISC DHCP Server (traditional)
apt install isc-dhcp-server
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200 ;
option routers 192.168.1.1 ;
option domain-name-servers 8.8.8.8, 8.8.4.4 ;
option domain-name " example.com " ;
default-lease-time 86400 ;
# Kea DHCP Server (modern, by ISC)
apt install kea-dhcp4-server
# Configuration: /etc/kea/kea-dhcp4.conf (JSON format)
# Kea supports MySQL/PostgreSQL backend for HA
ARP resolves IP addresses to MAC addresses on the local network segment. A host must know the Destination MAC address to construct an Ethernet frame. ARP is defined in RFC 826.
ARP Request: When host A (192.168.1.10) needs to send to host B (192.168.1.20):
Host A checks its ARP cache for 192.168.1.20 If not found, host A broadcasts an ARP request: “Who has 192.168.1.20? Tell 192.168.1.10” The ARP request is sent to MAC address ff:ff:ff:ff:ff:ff (broadcast) Host B responds with an ARP reply (unicast): “192.168.1.20 is at aa:bb:cc:dd:ee:ff” Host A caches this mapping and sends the IP packet in an Ethernet frame addressed to aa:bb:cc:dd:ee:ff sequenceDiagram
participant A as Host A (192.168.1.10)
participant N as Network
participant B as Host B (192.168.1.20)
A->>N: ARP Request (broadcast): Who has 192.168.1.20?
N->>B: ARP Request
B->>A: ARP Reply (unicast): 192.168.1.20 is at aa:bb:cc:dd:ee:ff 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hardware Type | Protocol Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| HW Addr Len | Proto Addr Len | Operation |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sender Hardware Address (6 bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sender Protocol Address (4 bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target Hardware Address (6 bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target Protocol Address (4 bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Hardware Type: 1 (Ethernet) Protocol Type: 0x0800 (IPv4) Operation: 1 (Request), 2 (Reply) ARP entries are cached to avoid repeated broadcasts. Cache behavior:
192.168.1.1 dev eth0 lladdr 00:11:22:33:44:55 REACHABLE
192.168.1.20 dev eth0 lladdr aa:bb:cc:dd:ee:ff STALE
192.168.1.30 dev eth0 <incomplete> DELAY
ip neigh del 192.168.1.20 dev eth0
ip neigh add 192.168.1.20 lladdr aa:bb:cc:dd:ee:ff dev eth0 nud permanent
Cache states (Linux ip neigh):
State Meaning REACHABLE Entry is valid and reachable STALE Entry is valid but unverified; will be confirmed before use DELAY Waiting before probing (after STALE entry used) PROBE Currently probing (ARP request sent) INCOMPLETE ARP request sent, no reply received yet FAILED ARP resolution failed PERMANENT Static entry, never expires
Cache timers vary by OS:
Linux: Reachable entries: 30 seconds. Stale entries: retained but re-verified (NUD — Neighbor Unreachability Detection) before use.Windows: 2-10 minutes for positive entries. 2 minutes for negative entries.macOS: 20 minutes for positive entries.A host sends a gratuitous ARP (GARP) to announce its own IP-to-MAC mapping. This is used for:
Duplicate address detection: If another host responds, there is an IP conflict.Address change notification: After a failover event (e.g., VRRP, CARP), the new owner of a virtual IP broadcasts a GARP to update switches’ MAC tables.VM migration: When a VM moves between physical hosts, a GARP updates the network’s forwarding tables.A gratuitous ARP is an ARP request where the source and target IP are the same, or an ARP reply sent Without a corresponding request. Some implementations ignore gratuitous ARPs as a security measure (to prevent ARP spoofing), but this breaks failover mechanisms.
ARP has no authentication. Any host on the local segment can send a forged ARP reply claiming to be Another IP address. This is called ARP spoofing or ARP poisoning and enables:
Man-in-the-middle attacks: The attacker claims to be the default gateway, intercepting all outbound traffic.Denial of service: The attacker claims to be a legitimate host, redirecting traffic to a non-existent MAC address.Mitigations include:
Dynamic ARP Inspection (DAI): Switches validate ARP packets against a trusted database ( populated by DHCP snooping).Static ARP entries: Manual ARP mappings that cannot be overwritten (impractical at scale).Network segmentation: VLANs limit the broadcast domain, reducing the attack surface.Arpwatch: A tool that monitors ARP traffic and alerts on changes to IP-MAC mappings.IPv6 addresses are 128 bits , represented as eight groups of four hexadecimal digits separated by Colons:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Leading zeros in each group can be omitted: 2001:db8:85a3:0:0:8a2e:370:7334 Consecutive groups of zeros can be replaced with :: (once per address): 2001:db8:85a3::8a2e:370:7334 The loopback address is ::1 The unspecified address is :: (used as source during address autoconfiguration) Prefix notation: 2001:db8:85a3::/48 (48-bit prefix) The IPv6 prefix for documentation is 2001:db8::/32 (RFC 3849) The total IPv6 address space is 2 128 = 340 , 282 , 366 , 920 , 938 , 463 , 463 , 374 , 607 , 431 , 768 , 211 , 456 2^{128} = 340,282,366,920,938,463,463,374,607,431,768,211,456 2 128 = 340 , 282 , 366 , 920 , 938 , 463 , 463 , 374 , 607 , 431 , 768 , 211 , 456 Addresses. This is approximately 3.4 × 10 38 3.4 \times 10^{38} 3.4 × 1 0 38 Or roughly 5 × 10 28 5 \times 10^{28} 5 × 1 0 28 addresses per Person on Earth.
To put this in perspective: if every atom on Earth’s surface were assigned an IPv6 address, there Would still be approximately 1.5 × 10 17 1.5 \times 10^{17} 1.5 × 1 0 17 addresses per atom remaining.
Unicast: Identifies a single interface. Packets sent to a unicast address are delivered to that Specific interface.
Prefix Scope Purpose ::1/128Link-local Loopback fe80::/10Link-local Automatic address for local communication fc00::/7Site-local (ULA) Unique Local Addresses (RFC 4193), equivalent to RFC 1918 2000::/3Global Globally routable addresses
Multicast: Identifies a group of interfaces. Packets sent to a multicast address are delivered To all members of the group. IPv6 has no broadcast — multicast replaces it.
Prefix Purpose ff00::/8All multicast ff02::1All nodes on the local link ff02::2All routers on the local link ff05::1All nodes in the site
Anycast: Assigned to multiple interfaces. Packets are routed to the “nearest” interface (by Routing protocol metric). Used for DNS anycast (e.g., 8.8.8.8 and 8.8.4.4 are anycast addresses Deployed globally). The routing protocol determines “nearest” based on metrics, not physical Distance.
The lower 64 bits of a unicast IPv6 address are the interface identifier (IID). There are two Methods for generating the IID:
EUI-64 (Modified): Derived from the 48-bit MAC address:
Split the MAC address into two 24-bit halves Insert ff:fe in the middle Flip the Universal/Local (U/L) bit (bit 6 of the first byte) Insert: 0011:22ff:fe33:4455
Flip U/L: 0211:22ff:fe33:4455
Privacy Extensions (RFC 7217): Generate random interface identifiers. The identifier is derived From a hash of the prefix, a random secret, and the interface index. This prevents tracking across Networks. Modern operating systems enable privacy extensions by default.
SLAAC allows hosts to generate their own IPv6 address without a DHCP server:
The router advertises the network prefix via Router Advertisement (RA) messages (ICMPv6). The host generates the interface identifier using EUI-64 or privacy extensions. The host combines the prefix and interface identifier to form a full address. The host performs Duplicate Address Detection (DAD) by sending a Neighbor Solicitation for its own address. If no response, the address is unique. DHCPv6 operates similarly to DHCPv4 but uses different message types and multicast addresses:
Stateless (SLAAC + DHCPv6): Host autoconfigures its address via SLAAC but uses DHCPv6 for additional options (DNS, NTP, domain search list). This is the most common deployment.Stateful: DHCPv6 assigns the full address (no SLAAC). Used in environments requiring strict address control.Rapid Commit: Two-message exchange (Solicit/Reply) instead of four-message (Solicit/Advertise/Request/Reply) for faster assignment.DHCPv6 uses UDP port 546 (client) and 547 (server). Multicast addresses: ff02::1:2 (All DHCP Relay Agents and Servers).
The IPv4-to-IPv6 transition has been ongoing since the 1990s. Several mechanisms allow IPv6 and IPv4 To coexist:
Dual-Stack: Hosts run both IPv4 and IPv6 simultaneously. The OS prefers IPv6 when both are Available (Happy Eyeballs algorithm, RFC 8305). This is the most common transition mechanism.
Tunneling: IPv6 traffic is encapsulated inside IPv4 packets:
6to4 (RFC 3056): Uses 2002::/16 prefix. Largely deprecated due to security concerns.Teredo (RFC 4380): Tunnels IPv6 over UDP through NAT. Deprecated.ISATAP (RFC 5214): Intra-site tunneling for enterprise networks.DS-Lite (RFC 6333): Carrier-grade tunneling.NAT64 and DNS64: NAT64 translates IPv6 addresses to IPv4 addresses at the network boundary. DNS64 synthesizes AAAA records for IPv4-only hosts by embedding the IPv4 address in the 64:ff9b::/96 prefix.
Off-by-one errors in usable host calculation. A /24 has 256 addresses. Subtract the network address (first) and broadcast address (last) to get 254 usable hosts. A /30 has 4 addresses and 2 usable hosts. A /31 has 2 addresses and 2 usable hosts (point-to-point links per RFC 3021).
Confusing network address with first usable host. The network address (e.g., 192.168.1.0/24) is not assignable to a host. The first usable host is 192.168.1.1.
NAT is not a security feature. NAT provides accidental address obscurity but does not provide security. A stateful firewall provides security. NAT without a firewall provides no meaningful protection against determined attackers. NAT was invented to address IPv4 address scarcity, not for security.
Forgetting about ARP when troubleshooting connectivity. If you can ping by IP but not by name, that is a DNS problem. If you cannot ping a host on the same subnet, check ARP. If ARP shows an incomplete entry, the host may be down or a firewall is blocking ARP.
IPv6 is not optional anymore. Major cloud providers (AWS, GCP, Azure) default to dual-stack or IPv6-only networking. Disabling IPv6 on Linux hosts (ipv6.disable=1 kernel parameter) causes issues with applications that expect IPv6 loopback to be available. SSH, PostgreSQL, and MySQL may fail to start with IPv6 disabled.
DHCP failover without shared state. If you run multiple DHCP servers, they must not offer the same address to different clients. Solutions include split scopes (each server serves a different range), DHCP failover protocol (RFC 3074), or a shared lease database (e.g., Kea with MySQL/PostgreSQL backend).
Ignoring link-local addressing. Link-local addresses (169.254.0.0/16 in IPv4, fe80::/10 in IPv6) are used for critical protocols (ARP in IPv4, NDP in IPv6, mDNS, LLMNR). If link-local communication is blocked by a firewall or switch configuration, these protocols fail silently.
Subnet overlap in multi-NIC hosts. If a host has interfaces on overlapping subnets (e.g., eth0: 192.168.1.0/24 and eth1: 192.168.1.0/24), the routing table may route traffic out the wrong interface. Always use non-overlapping subnets or configure policy routing.
CIDR boundary confusion. The prefix length must divide cleanly at a power-of-two boundary. You cannot have a “10.0.0.0/23” that starts at 10.0.1.0 — it must start at 10.0.0.0. The start address must have the host bits set to zero. 10.0.0.0/23 covers 10.0.0.0-10.0.1.255. 10.0.2.0/23 covers 10.0.2.0-10.0.3.255.
# Add an IP address to an interface
ip addr add 192.168.1.100/24 dev eth0
ip addr del 192.168.1.100/24 dev eth0
# Add a secondary IP address
ip addr add 10.0.0.1/24 dev eth0
# Bring an interface up/down
# View interface statistics
ip route add default via 192.168.1.1
ip route add 10.0.0.0/24 via 192.168.1.2
# Add a route with a specific source address
ip route add 10.0.0.0/24 via 192.168.1.2 src 192.168.1.100
ip route del 10.0.0.0/24 via 192.168.1.2
# View routing cache (deprecated, use 'ip route get' instead)
# Policy routing (advanced)
ip rule add from 192.168.1.100 table 100
ip route add default via 10.0.0.1 table 100
# View neighbor cache (IPv4 ARP and IPv6 NDP)
# View only reachable neighbors
ip neigh show nud reachable
# Flush the neighbor cache
# Add a permanent ARP entry
ip neigh add 192.168.1.100 lladdr aa:bb:cc:dd:ee:ff dev eth0 nud permanent
# Add a permanent NDP entry
ip -6 neigh add 2001:db8::1 lladdr aa:bb:cc:dd:ee:ff dev eth0 nud permanent
# Enable IPv6 forwarding (for routers)
sysctl -w net.ipv6.conf.all.forwarding= 1
# Disable IPv6 (not recommended, but sometimes necessary)
sysctl -w net.ipv6.conf.all.disable_ipv6= 1
sysctl -w net.ipv6.conf.default.disable_ipv6= 1
ip -6 addr add 2001:db8::1/64 dev eth0
# View IPv6 routing table
ping6 -c 3 2001:4860:4860::8888
traceroute6 2001:4860:4860::8888
In large networks, manual IP address management becomes error-prone. IPAM tools track address Allocations, prevent conflicts, and automate provisioning.
NetBox: Open-source DCIM/IPAM tool by DigitalOcean. Tracks IP addresses, VLANs, racks, devices, and cables. REST API for automation.phpIPAM: Open-source PHP-based IPAM. Supports IPv4/IPv6, VLANs, VRFs, and subnet scanning.Infoblox: Commercial DDI (DNS, DHCP, IPAM) platform. Widely used in enterprise environments.AWS VPC IPAM: Managed IPAM service for AWS VPCs. Integrates with AWS resource tagging.# Query available IPs in a prefix
curl -s -H " Authorization: Token $NETBOX_TOKEN " \
" https://netbox.example.com/api/ipam/prefixes/?prefix=10.0.0.0/24 " | jq
curl -s -X POST -H " Authorization: Token $NETBOX_TOKEN " \
-H " Content-Type: application/json " \
-d ' {"address": "10.0.0.100/24", "status": "active", "description": "web-server-01"} ' \
" https://netbox.example.com/api/ipam/ip-addresses/ " | jq
This topic covers the essential concepts and techniques related to ip addressing, including key principles and practical applications.
Key concepts include:
core concepts and definitions key principles and frameworks practical applications common techniques and methods evaluation and critical analysis A thorough understanding of these concepts, combined with regular practice and review, is essential for mastery of this topic.
Worked examples demonstrating the application of key concepts are covered in the detailed sub-pages linked above.