Lessons in this course (12)
2. IP addresses, subnets, ports, NAT and IPv6
IPv4 — 32 bits written as four numbers 192.168.1.25 (≈4.3 billion addresses — exhausted). IPv6 — 128 bits 2001:db8::1 (practically unlimited).
| Range | Meaning |
|---|---|
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private addresses (home/office/cloud VNets) — not routable on the internet |
127.0.0.1 / ::1 | Loopback — "this machine" (localhost) |
0.0.0.0 | "All interfaces" when a server listens |
169.254.x.x | No DHCP answer — self-assigned |
Subnet / CIDR: 192.168.1.0/24 = the first 24 bits are the network part → 256 addresses (254 usable hosts). /16 = 65,536 addresses. Cloud virtual networks (Azure VNet, AWS VPC) are designed with CIDR blocks and subnets for web, app and database tiers.
DHCP gives devices an IP, gateway and DNS automatically. Default gateway = the router to other networks.
NAT (network address translation): your home router has one public IP; it rewrites many private addresses to it and tracks connections — that's why your laptop isn't directly reachable from the internet. Port forwarding opens a hole for a specific port.
Ports (0–65535) identify the program:
| Port | Service |
|---|---|
| 80 / 443 | HTTP / HTTPS |
| 22 | SSH |
| 3389 | Remote Desktop (RDP) |
| 1433 | SQL Server |
| 5432 / 3306 | PostgreSQL / MySQL |
| 6379 | Redis |
| 25 / 587 | SMTP (mail) |
| 53 | DNS |
| 5000–5001, 7000+ | Typical ASP.NET Core dev ports |
A socket = IP + port + protocol; a TCP connection is identified by (client IP, client port, server IP, server port).