1---
2name: network
3description: Understand and troubleshoot computer networks with TCP/IP, DNS, routing, and diagnostic tools.
4metadata:
5 source: https://skillmd.com/skills/modbender/network
6 clawdbot:
7 emoji: 🌐
8 os:
9 - linux
10 - darwin
11 - win32
12---
13
14# Network Fundamentals
15
16## TCP/IP Basics
17- TCP guarantees delivery with retransmission — use for reliability (HTTP, SSH, databases)
18- UDP is fire-and-forget — use for speed when loss is acceptable (video, gaming, DNS queries)
19- Port numbers: 0-1023 privileged (need root), 1024-65535 available — common services have well-known ports
20- Ephemeral ports for client connections — OS assigns randomly from high range
21
22## DNS
23- DNS resolution is cached at multiple levels — browser, OS, router, ISP — flush all when debugging
24- TTL determines cache duration — lower before migrations, raise after for performance
25- A record for IPv4, AAAA for IPv6, CNAME for aliases, MX for mail
26- CNAME cannot exist at zone apex (root domain) — use A record or provider-specific alias
27- `dig` and `nslookup` query DNS directly — bypass local cache for accurate results
28
29## IP Addressing
30- Private ranges: 10.x.x.x, 172.16-31.x.x, 192.168.x.x — not routable on internet
31- CIDR notation: /24 = 256 IPs, /16 = 65536 IPs — each bit halves or doubles the range
32- 127.0.0.1 is localhost — 0.0.0.0 means all interfaces, not a valid destination
33- NAT translates private to public IPs — most home/office networks use this
34- IPv6 eliminates NAT need — but dual-stack with IPv4 still common
35
36## Common Ports
37- 22: SSH — 80: HTTP — 443: HTTPS — 53: DNS
38- 25/465/587: SMTP (mail sending) — 143/993: IMAP — 110/995: POP3
39- 3306: MySQL — 5432: PostgreSQL — 6379: Redis — 27017: MongoDB
40- 3000/8080/8000: Common development servers
41
42## Troubleshooting Tools
43- `ping` tests reachability — but ICMP may be blocked, no response doesn't mean down
44- `traceroute`/`tracert` shows path — identifies where packets stop or slow down
45- `netstat -tulpn` or `ss -tulpn` shows listening ports — find what's using a port
46- `curl -v` shows full HTTP transaction — headers, timing, TLS negotiation
47- `tcpdump` and Wireshark capture packets — last resort for deep debugging
48
49## Firewalls and NAT
50- Stateful firewalls track connections — allow response to outbound requests automatically
51- Port forwarding maps external port to internal IP:port — required to expose services behind NAT
52- Hairpin NAT for internal access to external IP — not all routers support it
53- UPnP auto-configures port forwarding — convenient but security risk, disable on servers
54
55## Load Balancing
56- Round-robin distributes sequentially — simple but ignores server capacity
57- Least connections sends to least busy — better for varying request durations
58- Health checks remove dead servers — configure appropriate intervals and thresholds
59- Sticky sessions (affinity) keep user on same server — needed for stateful apps, breaks scaling
60
61## VPNs and Tunnels
62- VPN encrypts traffic to exit point — all traffic appears from VPN server IP
63- Split tunneling sends only some traffic through VPN — reduces latency for local resources
64- WireGuard is modern and fast — simpler than OpenVPN, better performance
65- SSH tunnels for ad-hoc port forwarding — `ssh -L local:remote:port` creates secure tunnel
66
67## SSL/TLS
68- TLS 1.2 minimum, prefer 1.3 — older versions have known vulnerabilities
69- Certificate chain: leaf → intermediate → root — missing intermediate causes validation failures
70- SNI allows multiple certs on one IP — older clients without SNI get default cert
71- Let's Encrypt certs expire in 90 days — automate renewal or face outages
72
73## Common Mistakes
74- Assuming DNS changes are instant — TTL means old records persist in caches
75- Blocking ICMP entirely — breaks path MTU discovery, causes mysterious failures
76- Forgetting IPv6 — services may be accessible on IPv6 even with IPv4 firewall
77- Hardcoding IPs instead of hostnames — breaks when IPs change
78- Not checking both TCP and UDP — some services need UDP (DNS, VPN, game servers)
79- Confusing latency and bandwidth — high bandwidth doesn't mean low latency