Networking Fundamentals
Master essential networking concepts for DevOps: TCP/IP, DNS, HTTP/HTTPS, ports, firewalls, and network troubleshooting.
Master essential networking concepts for DevOps: TCP/IP, DNS, HTTP/HTTPS, ports, firewalls, and network troubleshooting. This hands-on tutorial focuses on practical implementation of networking fundamentals concepts.
Networking Fundamentals
Networking is the backbone of modern infrastructure. As a DevOps engineer, understanding network fundamentals is crucial for designing, deploying, and troubleshooting systems.
TCP/IP Model
The TCP/IP model is the foundation of internet communication:
┌─────────────────────────────────────────┐
│ Layer 4: Application (HTTP, FTP, SSH) │
├─────────────────────────────────────────┤
│ Layer 3: Transport (TCP, UDP) │
├─────────────────────────────────────────┤
│ Layer 2: Internet (IP, ICMP) │
├─────────────────────────────────────────┤
│ Layer 1: Network Access (Ethernet) │
└─────────────────────────────────────────┘
OSI Model vs TCP/IP
| OSI Layer | TCP/IP Layer | Protocols/Devices |
|---|---|---|
| 7. Application | Application | HTTP, HTTPS, FTP, SSH, DNS |
| 6. Presentation | SSL/TLS, JPEG, ASCII | |
| 5. Session | NetBIOS, RPC | |
| 4. Transport | Transport | TCP, UDP |
| 3. Network | Internet | IP, ICMP, Routers |
| 2. Data Link | Network Access | Ethernet, MAC, Switches |
| 1. Physical | Cables, Hubs, Signals |
IP Addresses and Subnetting
IPv4 Addressing
IPv4 Address: 192.168.1.100
│││││││││││││
││││││││││└┴┴─ Host ID
││││││││└┴┴── Network ID
└┴┴┴┴┴┴┴──── IP Address
Classes:
- Class A: 1.0.0.0 to 126.0.0.0 (Subnet: 255.0.0.0 /8)
- Class B: 128.0.0.0 to 191.255.0.0 (Subnet: 255.255.0.0 /16)
- Class C: 192.0.0.0 to 223.255.255.0 (Subnet: 255.255.255.0 /24)
Private Ranges:
- 10.0.0.0/8 (10.0.0.0 - 10.255.255.255)
- 172.16.0.0/12 (172.16.0.0 - 172.31.255.255)
- 192.168.0.0/16 (192.168.0.0 - 192.168.255.255)
CIDR Notation
| CIDR | Subnet Mask | Total IPs | Usable IPs |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /32 | 255.255.255.255 | 1 | 1 |
IPv6 Addressing
IPv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
└─┬─┘└─┬──┘└─┬──┘└┬┘└┬┘└─┬──┘└┬──┘└┬┘
Global│Site │Sub │ │ │ │ │
Routing│ │ │ │ │ │ │
Prefix │ │ │ │ │ │ │
└─────┴─────┴──┘ │ │ │
│ │ │
Interface Identifier─┴────┴────┘
# Shortened form
2001:db8:85a3::8a2e:370:7334
TCP vs UDP
TCP (Transmission Control Protocol)
Characteristics:
- Connection-oriented
- Reliable delivery (acknowledgments, retransmission)
- Ordered delivery
- Flow control
- Error checking
Use Cases:
- HTTP/HTTPS (web)
- SSH
- FTP
- Email (SMTP, IMAP)
UDP (User Datagram Protocol)
Characteristics:
- Connectionless
- Unreliable (no guarantees)
- No ordering guarantees
- Low overhead
- Faster than TCP
Use Cases:
- DNS queries
- Video streaming
- Online gaming
- VoIP
Common Ports
| Port | Protocol | Use |
|---|---|---|
| 20/21 | FTP | File Transfer |
| 22 | SSH | Secure Shell |
| 25 | SMTP | Email Sending |
| 53 | DNS | Domain Name System |
| 80 | HTTP | Web (Unencrypted) |
| 443 | HTTPS | Web (Encrypted) |
| 3306 | MySQL | MySQL Database |
| 5432 | PostgreSQL | PostgreSQL Database |
| 6379 | Redis | Redis Cache |
| 8080 | HTTP Alt | Alternative HTTP |
| 27017 | MongoDB | MongoDB Database |
DNS (Domain Name System)
DNS translates human-readable domain names into IP addresses.
How DNS Works
DNS Record Types
| Record | Purpose | Example |
|---|---|---|
| A | IPv4 address | techcoder.io. 300 IN A 192.0.2.1 |
| AAAA | IPv6 address | techcoder.io. 300 IN AAAA 2001:db8::1 |
| CNAME | Alias to another domain | www.techcoder.io. CNAME techcoder.io. |
| MX | Mail server | techcoder.io. MX 10 mail.techcoder.io. |
| TXT | Text information | techcoder.io. TXT "v=spf1 include:_spf.google.com" |
| NS | Name server | techcoder.io. NS ns1.cloudflare.com. |
| SOA | Start of authority | Zone configuration |
DNS Commands
# DNS lookup
dig techcoder.io
dig +short techcoder.io
dig techcoder.io A
dig techcoder.io MX
# Reverse DNS
dig -x 192.0.2.1
# Trace DNS resolution
dig +trace techcoder.io
# Check DNS propagation
nslookup techcoder.io 8.8.8.8 # Google DNS
nslookup techcoder.io 1.1.1.1 # Cloudflare DNS
HTTP vs HTTPS
HTTP (HyperText Transfer Protocol)
Client Server
| |
|---- GET /index.html --->|
| |
|<--- 200 OK + HTML ------|
| |
- Port: 80
- Unencrypted
- Fast but insecure
- Vulnerable to interception
HTTPS (HTTP Secure)
Client Server
| |
|---- TLS Handshake ----->|
|<--- Certificate --------|
|---- Key Exchange ------>|
|<--- Encrypted comms ----|
| |
- Port: 443
- Encrypted with TLS/SSL
- Authenticated
- Protects against MITM attacks
TLS/SSL Versions
| Version | Status | Security |
|---|---|---|
| SSL 2.0 | Deprecated | Insecure |
| SSL 3.0 | Deprecated | Insecure |
| TLS 1.0 | Deprecated | Weak |
| TLS 1.1 | Deprecated | Weak |
| TLS 1.2 | Supported | Secure |
| TLS 1.3 | Recommended | Most Secure |
Firewalls and Security
Types of Firewalls
-
Network Firewalls
- Hardware devices
- Filter by IP, port, protocol
- Example: Cisco ASA, pfSense
-
Host-based Firewalls
- Software on individual systems
- iptables, firewalld, ufw
-
Web Application Firewalls (WAF)
- Filter HTTP/HTTPS traffic
- Protect against SQL injection, XSS
- Example: AWS WAF, Cloudflare WAF
Firewall Rules Best Practices
# Default Deny Policy
- Deny all incoming by default
- Allow only what's needed
- Log denied attempts
- Regular rule reviews
# Rule Order Matters
1. Allow specific management access
2. Allow required services
3. Allow established connections
4. Deny everything else
5. Log suspicious activity
Network Troubleshooting
Essential Commands
# Connectivity test
ping google.com -c 4 # Send 4 packets
ping6 ipv6.google.com # IPv6 test
# Trace route
traceroute google.com
tracepath google.com # No root required
mtr google.com # Real-time stats
# DNS issues
dig google.com
dig @8.8.8.8 google.com # Test specific DNS
nslookup google.com
# Check connections
netstat -tuln # Listening ports
ss -tuln # Modern alternative
lsof -i :80 # What's using port 80
# Packet capture
sudo tcpdump -i eth0 port 80
sudo tcpdump -i any host 192.168.1.1
# Network interfaces
ip addr show
ip route show
# Bandwidth test
iperf3 -c server.example.com
curl -o /dev/null http://speedtest.tele2.net/10MB.zip
Common Issues and Solutions
| Symptom | Likely Cause | Solution |
|---|---|---|
| Can't reach server | Firewall blocking | Check iptables/firewalld |
| DNS not resolving | DNS server issue | Test with dig @8.8.8.8 |
| Connection refused | Service not running | Check service status |
| Connection timeout | Network path issue | traceroute to identify |
| Slow transfer | Bandwidth/congestion | iperf3 test, check QoS |
Quiz
Quiz
Question 1 of 5Which protocol is connectionless and provides no delivery guarantees?
Next Steps
Now let's explore load balancers and reverse proxies, essential components for scaling and securing applications.