Lessons in this course (12)

2. IP addresses, subnets, ports, NAT and IPv6

Basic★ Must knowLesson 2 of 12

IPv4 — 32 bits written as four numbers 192.168.1.25 (≈4.3 billion addresses — exhausted). IPv6 — 128 bits 2001:db8::1 (practically unlimited).

RangeMeaning
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private addresses (home/office/cloud VNets) — not routable on the internet
127.0.0.1 / ::1Loopback — "this machine" (localhost)
0.0.0.0"All interfaces" when a server listens
169.254.x.xNo 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:

PortService
80 / 443HTTP / HTTPS
22SSH
3389Remote Desktop (RDP)
1433SQL Server
5432 / 3306PostgreSQL / MySQL
6379Redis
25 / 587SMTP (mail)
53DNS
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).