Lesson 1.3: IP Addresses and Port Management
Completion requirements
IP Address Fundamentals
Private IP Ranges (RFC 1918)
These ranges are reserved for private networks:
- Class A: 10.0.0.0/8 (10.0.0.0 - 10.255.255.255)
- Class B: 172.16.0.0/12 (172.16.0.0 - 172.31.255.255)
- Class C: 192.168.0.0/16 (192.168.0.0 - 192.168.255.255)
Localhost and Loopback
- 127.0.0.1: IPv4 loopback (localhost)
- ::1: IPv6 loopback
- 0.0.0.0: All interfaces (bind to all IPs)
Port Management Strategy
Well-Known Ports (0-1023)
Reserved for system services:
- 22: SSH
- 53: DNS
- 80: HTTP
- 443: HTTPS
MCT Services Port Allocation
Our current port strategy:
# Core Services
80/443 - Traefik (Reverse Proxy)
53 - Pi-hole (DNS)
# Application Services
8080 - Nextcloud
8081 - Stash
8082 - MeTube
8083 - Dashy
8084 - Keycloak
8085 - Moodle
# Database Services
3306 - MariaDB
5432 - PostgreSQL
6379 - Redis
# Monitoring
9090 - Prometheus
3000 - Grafana
Port Conflict Resolution
Common strategies for avoiding conflicts:
- Port Mapping: Use Docker port mapping
- Reverse Proxy: Single entry point (port 80/443)
- Port Ranges: Allocate ranges by service type
- Documentation: Maintain port registry
Docker Port Management
Docker Compose port mapping examples:
services:
nextcloud:
ports:
- 8080:80 # Host:Container
traefik:
ports:
- 80:80 # HTTP
- 443:443 # HTTPS
- 8080:8080 # Dashboard
Network Interface Binding
Control which interfaces services bind to:
# Bind to localhost only
127.0.0.1:8080:80
# Bind to specific interface
192.168.1.100:8080:80
# Bind to all interfaces
0.0.0.0:8080:80
Firewall Considerations
Essential firewall rules for personal cloud:
# Allow HTTP/HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Allow SSH (if needed)
sudo ufw allow 22/tcp
# Allow specific application ports
sudo ufw allow 8080:8090/tcp
Practical Exercise
Task: Design your port allocation strategy
- Audit current port usage:
netstat -tulpn - Design port allocation scheme
- Document port assignments
- Test port availability
- Configure firewall rules
Troubleshooting Tools
# Check port usage
netstat -tulpn | grep :8080
ss -tulpn | grep :8080
# Test port connectivity
telnet localhost 8080
nc -zv localhost 8080
# Check which process uses a port
lsof -i :8080Last modified: Thursday, 6 November 2025, 8:48 AM