What is an IP Address?
An IP (Internet Protocol) address is a unique numerical identifier assigned to each
device connected to a network. It serves two main purposes: identifying the host or
network interface and providing the location of the host in the network.
IPv4 Structure
IPv4 addresses are 32-bit numbers typically written in dotted decimal notation,
consisting of four octets (8-bit segments) separated by periods.
Example: 192.168.1.100
- Binary:
11000000.10101000.00000001.01100100
- Each octet ranges from 0 to 255
IP Address Classes
IPv4 addresses are divided into five classes:
- Class A: 1.0.0.0 to 126.255.255.255 (Default /8) - For very
large networks.
- Class B: 128.0.0.0 to 191.255.255.255 (Default /16) - For
medium to large networks.
- Class C: 192.0.0.0 to 223.255.255.255 (Default /24) - For small
networks.
- Class D: 224.0.0.0 to 239.255.255.255 - For Multicast groups.
- Class E: 240.0.0.0 to 255.255.255.255 - Reserved for
experimental purposes.
Special IP Addresses
- Private Ranges (RFC 1918):
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- Loopback: 127.0.0.0/8 (127.0.0.1 is localhost)
- APIPA: 169.254.0.0/16
- Reserved: 0.0.0.0 (Default), 255.255.255.255 (Broadcast)
Subnet Masks
A subnet mask is a 32-bit number that divides an IP address into network and host
portions. It determines which part of an IP address identifies the network and which
part identifies the host.
Common Subnet Masks
| CIDR |
Mask |
Wildcard |
Hosts |
| /8 |
255.0.0.0 |
0.255.255.255 |
16,777,214 |
| /16 |
255.255.0.0 |
0.0.255.255 |
65,534 |
| /24 |
255.255.255.0 |
0.0.0.255 |
254 |
| /25 |
255.255.255.128 |
0.0.0.127 |
126 |
| /26 |
255.255.255.192 |
0.0.0.63 |
62 |
| /27 |
255.255.255.224 |
0.0.0.31 |
30 |
| /28 |
255.255.255.240 |
0.0.0.15 |
14 |
| /29 |
255.255.255.248 |
0.0.0.7 |
6 |
| /30 |
255.255.255.252 |
0.0.0.3 |
2 |
| /31 |
255.255.255.254 |
0.0.0.1 |
2* (PtP) |
| /32 |
255.255.255.255 |
0.0.0.0 |
1 |
Subnetting Process
Step 1: Determine requirements (number of subnets or hosts).
Step 2: Calculate Subnet Bits: 2^n >= subnets.
Step 3: Calculate Host Bits: 2^h - 2 >= hosts.
Step 4: Determine New Subnet Mask (Add subnet bits to original
mask).
Example: Creating 4 Subnets from 192.168.1.0/24
- Need 4 subnets -> 2 bits borrowed (2^2 = 4).
- New CIDR: /24 + 2 = /26 (Mask: 255.255.255.192).
- Increment: 64 (256 - 192).
Resulting Subnets: .0, .64, .128, .192.
CIDR (Classless Inter-Domain Routing)
CIDR allows for flexible IP allocation and route aggregation, replacing the old
classful system.
Benefits
- Eliminates class limitations.
- Reduces routing table size (Supernetting).
- Efficient address allocation.
VLSM (Variable Length Subnet Masking)
VLSM allows you to use different subnet masks for different subnets within the same
network. This maximizes IP address efficiency.
Example: 192.168.1.0/24
- Subnet A (100 hosts): /25
- Subnet B (50 hosts): /26
- Subnet C (25 hosts): /27
- Subnet D (10 hosts): /28
Binary and IP Addressing
Powers of 2: 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
Decimal to Binary Example (192): 128 + 64 = 11000000
AND Operation: Used to find the network address.
IP: 11000000.10101000.00000001.01100100 (192.168.1.100)
Mask: 11111111.11111111.11111111.00000000 (255.255.255.0)
Net: 11000000.10101000.00000001.00000000 (192.168.1.0)
Supernetting (Route Aggregation)
Combining multiple smaller networks into one larger network (opposite of subnetting)
to reduce routing table size.
Example: Combining four /24 networks into one /22 supernet.
Wildcard Masks
Inverse of a subnet mask (255.255.255.255 - Subnet Mask), used in ACLs.
Example: Mask 255.255.255.0 -> Wildcard 0.0.0.255
ACL Usage: 0 = Match exact, 255 = Any value.
IPv6 Basics
128-bit addresses in hexadecimal (e.g., 2001:0db8::1). Supports Unicast,
Multicast, and Anycast.
- Structure: 8 groups of 4 hex digits.
- Compression: Leading zeros omitted, :: used once for zeros.
NAT (Network Address Translation)
Translates private IPs to public IPs to conserve addresses and add security.
- Static NAT: One-to-one mapping.
- Dynamic NAT: Pool of public IPs.
- PAT (Overload): Many-to-one using ports.
Common Terms
- Broadcast Domain: A network segment where broadcast packets can
reach all devices.
- Default Gateway: The router that forwards traffic to other
networks.
- DHCP: Automatically assigns IP addresses.
- DNS: Translates domain names to IPs.
- MAC Address: Physical hardware address.
- MTU: Maximum Transmission Unit.
- TTL: Time To Live (hop limit).
Quick Formulas
- Subnets:
2^n (n = borrowed bits)
- Hosts:
2^h - 2 (h = host bits)
- Increment: 256 - subnet mask octet value
Troubleshooting & Best Practices
- Plan for growth (allocate more than needed).
- Document all IP assignments.
- Use RFC 1918 Private ranges internally.
- Check for overlapping subnets.
- Test calculations before deployment.
- Avoid using /31 unless P2P specific.