What is IP Subnetting and why is it used?
IP Subnetting is the architectural practice of splitting a larger physical IP network into smaller, logical sub-networks (subnets). Network administrators deploy subnetting to optimize IP address allocation, isolate security domains, and control broadcast traffic.
Without subnets, all devices in an organization would reside in a single broadcast domain, causing significant packet collisions and high latency. Subnet boundaries are designated using a Subnet Mask, which tells routers which portions of an IP address represent the network route and which portions identify the target device (host).
How do you calculate a Subnet Mask and Network Address?
Subnetting is computed using bitwise mathematical operations on binary representation:
- Convert to Binary: Convert both the IP Address and the Subnet Mask into their 32-bit binary values.
- Compute Network Address (Bitwise AND): Perform a bitwise AND operation on each corresponding bit of the IP and the mask. Where both bits are 1, the result is 1; otherwise, it is 0.
- Compute Broadcast Address (Bitwise OR with NOT Mask): Perform a bitwise OR between the Network Address and the bitwise inversion (NOT) of the Subnet Mask.
- Determine Usable Hosts: Usable hosts are those bounded between the Network Address and Broadcast Address. The formula is \(2^{32 - \text{prefix}} - 2\) (except for /31 and /32 routes).
What is CIDR notation vs Classful addressing?
Historically, IP addresses were allocated according to a strict Classful IP addressing scheme (Class A, Class B, Class C, etc.), where the size of the network prefix was pre-defined by the first few bits of the IP address. For instance, a Class C address always had a 24-bit network prefix.
To resolve massive IP address wastage, the industry migrated to CIDR (Classless Inter-Domain Routing) in 1993. CIDR allows variable-length subnet masking (VLSM). In CIDR notation, a slash (/) followed by a decimal number (like `/24`) specifies exactly how many bits of the 32-bit IP address represent the network routing prefix.
What is the difference between Public and Private IP Addresses?
Public IP addresses are globally unique and routable on the public internet. They are assigned by Internet Service Providers (ISPs) and coordinated by organizations like IANA and RIRs.
Private IP addresses are reserved under RFC 1918 specifications for internal enterprise LAN networks. They are non-routable on the public internet and can be repeated across different private organizations. Routers block private ranges, relying on Network Address Translation (NAT) to map internal private hosts to a single public IP.
RFC 1918 Ranges: 10.0.0.0/8 | 172.16.0.0/12 | 192.168.0.0/16
Why do computers use binary numbers in networking?
Computers process information via electrical gates that exist in two states: high voltage (1) or low voltage (0). This forms base-2 mathematics, or binary code.
In TCP/IP routing, routing decisions must be calculated inside network chips at gigabit speeds. Routers inspect headers using binary masks since hardware-level bit shifts and logical AND logic gates take only a fraction of a nanosecond, allowing near-instantaneous routing decisions.