Other Application Protocols
Other Application Protocols¶
Overview¶
Besides HTTP, networks use various application layer protocols. This chapter covers DHCP, FTP, email protocols (SMTP, POP3, IMAP), SSH, Telnet, WebSocket, and more.
Difficulty: ββ
Learning Objectives: - Understand each protocol's role and operating principles - Familiarize with protocol-specific port numbers - Identify security considerations - Learn practical usage methods
Table of Contents¶
1. DHCP¶
DHCP Overview¶
DHCP (Dynamic Host Configuration Protocol) is a protocol that automatically assigns IP addresses and network configurations to devices connected to a network.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DHCP Basics β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: UDP 67 (server), UDP 68 (client) β
β RFC: 2131 β
β β
β Assigned Information: β
β - IP address β
β - Subnet mask β
β - Default gateway β
β - DNS server β
β - Lease time β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DHCP DORA Process¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DHCP DORA Process β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client] [DHCP Server] β
β (No IP) (192.168.1.1) β
β β β β
β βββ(1) DHCP Discover ββββββββββββββββββΆ β β
β β Source: 0.0.0.0 β β
β β Destination: 255.255.255.255 (broadcast) β
β β "I need an IP address" β β
β β β β
β βββ(2) DHCP Offer ββββββββββββββββββββββ β
β β "I offer 192.168.1.100" β β
β β Subnet: 255.255.255.0 β β
β β Gateway: 192.168.1.1 β β
β β DNS: 8.8.8.8 β β
β β Lease time: 24 hours β β
β β β β
β βββ(3) DHCP Request βββββββββββββββββββΆ β β
β β "I request 192.168.1.100" β β
β β β β
β βββ(4) DHCP Ack ββββββββββββββββββββββββ β
β β "192.168.1.100 approved" β β
β β β β
β [IP Configuration Complete] β β
β (192.168.1.100) β β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DORA: Discover β Offer β Request β Acknowledge
DHCP Message Types¶
| Message | Direction | Description |
|---|---|---|
| DISCOVER | Client β Server | Request IP address (broadcast) |
| OFFER | Server β Client | Offer IP address |
| REQUEST | Client β Server | Accept offer or renew request |
| ACK | Server β Client | Approve request |
| NAK | Server β Client | Deny request |
| RELEASE | Client β Server | Release IP |
| INFORM | Client β Server | Request additional configuration |
DHCP Lease Process¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DHCP Lease Time β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Lease start β
β β β
β βββββββββββββββββββββββββββββββββββββββ Lease time (T) β
β β β
β βββββββββββββββββ T/2 (50%) β
β β β β
β β ββ Renewal attempt (Request to server) β
β β If successful: lease time extended β
β β β
β βββββββββββββββββββββββββββββ T * 7/8 (87.5%) β
β β β β
β β ββ Rebinding attempt β
β β (broadcast) β
β β β
β βββββββββββββββββββββββββββββββββββββββ T (100%) β
β β β
β ββ Lease expired β
β IP released β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DHCP-Related Commands¶
# Linux - DHCP client
# Release IP
sudo dhclient -r eth0
# Renew IP
sudo dhclient eth0
# Verbose output
sudo dhclient -v eth0
# Windows
ipconfig /release # Release IP
ipconfig /renew # Renew IP
# macOS
sudo ipconfig set en0 DHCP # Reset DHCP
2. FTP¶
FTP Overview¶
FTP (File Transfer Protocol) is a protocol for transferring files between client and server.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FTP Basic Info β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: β
β - Control connection: TCP 21 β
β - Data connection: TCP 20 (Active) or random port (Passive) β
β β
β Features: β
β - Uses two channels (control + data) β
β - Plaintext transmission (security vulnerable) β
β - ASCII/Binary transfer modes β
β - Active/Passive modes β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FTP Active vs Passive Mode¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Active Mode β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client] [FTP Server] β
β (Random port N) (Port 21, 20) β
β β β β
β βββ(1) Control connection (N β 21) ββββΆ β β
β β "PORT N+1" β β
β β β β
β βββ(2) Data connection (20 β N+1) βββββββ β
β β Server connects to client β β
β β β β
β β» Problems occur if client firewall blocks external connectionsβ
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Passive Mode β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client] [FTP Server] β
β (Random port) (Port 21, random port) β
β β β β
β βββ(1) Control connection (N β 21) ββββΆ β β
β β "PASV" β β
β β β β
β ββββββ Response: Use port P βββββββββββββ β
β β β β
β βββ(2) Data connection (N+1 β P) ββββββββΆ β β
β β Client connects to server β β
β β β β
β β» Client always initiates connection β fewer firewall issues β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FTP Main Commands¶
| Command | Description | Example |
|---|---|---|
| USER | Send username | USER username |
| PASS | Send password | PASS password |
| LIST | Directory listing | LIST |
| CWD | Change directory | CWD /home/user |
| PWD | Print working directory | PWD |
| RETR | Download file | RETR file.txt |
| STOR | Upload file | STOR file.txt |
| DELE | Delete file | DELE file.txt |
| MKD | Create directory | MKD newdir |
| RMD | Remove directory | RMD olddir |
| PASV | Passive mode | PASV |
| PORT | Active mode | PORT 192,168,1,100,4,1 |
| QUIT | Close connection | QUIT |
FTP Response Codes¶
| Code Range | Meaning | Examples |
|---|---|---|
| 1xx | Positive preliminary | 150 File status OK |
| 2xx | Positive completion | 200 Command OK, 226 Transfer complete |
| 3xx | Positive intermediate | 331 Username OK, password needed |
| 4xx | Transient negative | 421 Service unavailable |
| 5xx | Permanent negative | 530 Login failed, 550 No permission |
FTP Client Usage¶
# Basic FTP client
ftp ftp.example.com
# Commands after connection
ftp> user username
ftp> pass password
ftp> ls # List files
ftp> cd directory # Change directory
ftp> get file.txt # Download
ftp> put file.txt # Upload
ftp> binary # Binary mode
ftp> ascii # ASCII mode
ftp> passive # Toggle passive mode
ftp> bye # Close connection
SFTP and FTPS¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FTP vs SFTP vs FTPS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β FTP β SFTP β FTPS β
β (Plaintext) β (SSH-based) β (TLS/SSL-based) β
β β β β
β βββββββββββ β βββββββββββ β βββββββββββ β
β β FTP β β β SFTP β β β FTP β β
β βββββββββββ€ β βββββββββββ€ β βββββββββββ€ β
β β TCP β β β SSH β β β TLS/SSL β β
β βββββββββββ β βββββββββββ€ β βββββββββββ€ β
β β β TCP β β β TCP β β
β Port: 21 β βββββββββββ β βββββββββββ β
β β β β
β Security: Noneβ Port: 22 β Port: 990 (implicit) β
β β Security: SSH β 21 (explicit) β
β β encryption β Security: TLS encryption β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Recommendation: Use SFTP (SSH-based, single port)
3. Email Protocols¶
Email Transmission Structure¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Email Transmission Process β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Sender] [Sending Server] [Receiving Server] [Recipient]β
β alice@a.com mail.a.com mail.b.com bob@b.com β
β β β β β β
β βββ(1) SMTPββΆβ β β β
β β (compose)β β β β
β β β β β β
β β βββ(2) SMTPββββββββΆβ β β
β β β (server-to-server) β β
β β β β β β
β β β βββ(3) StoreββΆβ β
β β β β (mailbox)β β
β β β β β β
β β β βββ(4) POP3/IMAPβββ β
β β β β (retrieve) β β
β β
β Protocols: β
β - SMTP: Mail transmission (sending) β
β - POP3: Mail retrieval (download and delete) β
β - IMAP: Mail retrieval (keep on server) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SMTP (Simple Mail Transfer Protocol)¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SMTP Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: TCP 25 (default), 587 (submission), 465 (SSL) β
β RFC: 5321 β
β Purpose: Email transmission β
β β
β SMTP Session Example: β
β β
β C: Connect (TCP 25) β
β S: 220 mail.example.com ESMTP ready β
β C: EHLO client.example.com β
β S: 250-mail.example.com Hello β
β S: 250-AUTH LOGIN PLAIN β
β S: 250 STARTTLS β
β C: MAIL FROM:<alice@example.com> β
β S: 250 OK β
β C: RCPT TO:<bob@example.com> β
β S: 250 OK β
β C: DATA β
β S: 354 Start mail input β
β C: Subject: Test β
β C: β
β C: Hello, this is a test. β
β C: . β
β S: 250 OK Message queued β
β C: QUIT β
β S: 221 Bye β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SMTP Main Commands¶
| Command | Description |
|---|---|
| HELO/EHLO | Client identification (EHLO is extended SMTP) |
| MAIL FROM | Specify sender |
| RCPT TO | Specify recipient |
| DATA | Start mail content |
| QUIT | Close connection |
| AUTH | Authentication |
| STARTTLS | Start TLS encryption |
| RSET | Reset transaction |
POP3 (Post Office Protocol v3)¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β POP3 Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: TCP 110 (default), 995 (SSL/TLS) β
β RFC: 1939 β
β Purpose: Email retrieval (download) β
β β
β Features: β
β - Downloads mail locally β
β - Deletes from server (by default) β
β - Suitable for single device β
β - Offline reading possible β
β β
β POP3 Session Example: β
β β
β S: +OK POP3 server ready β
β C: USER alice β
β S: +OK β
β C: PASS password123 β
β S: +OK Logged in β
β C: STAT β
β S: +OK 3 1024 β
β C: LIST β
β S: +OK 3 messages β
β S: 1 512 β
β S: 2 256 β
β S: 3 256 β
β S: . β
β C: RETR 1 β
β S: +OK 512 octets β
β S: (mail content) β
β S: . β
β C: DELE 1 β
β S: +OK Deleted β
β C: QUIT β
β S: +OK Bye β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
IMAP (Internet Message Access Protocol)¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β IMAP Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: TCP 143 (default), 993 (SSL/TLS) β
β RFC: 3501 (IMAP4) β
β Purpose: Email retrieval (server synchronization) β
β β
β Features: β
β - Stores mail on server β
β - Synchronizes across multiple devices β
β - Folder management available β
β - Supports partial download β
β - Requires online connection β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
POP3 vs IMAP Comparison¶
| Feature | POP3 | IMAP |
|---|---|---|
| Mail storage location | Local (download) | Server |
| Multi-device sync | Difficult | Supported |
| Offline reading | Easy | Limited |
| Server storage space | Small | Large needed |
| Folder management | Limited | Supported |
| Partial download | Not possible | Possible |
| Best use case | Single device | Multiple devices |
Email Port Summary¶
| Protocol | Port | Security |
|---|---|---|
| SMTP | 25 | Plaintext |
| SMTP Submission | 587 | STARTTLS |
| SMTPS | 465 | SSL/TLS |
| POP3 | 110 | Plaintext |
| POP3S | 995 | SSL/TLS |
| IMAP | 143 | Plaintext |
| IMAPS | 993 | SSL/TLS |
4. SSH¶
SSH Overview¶
SSH (Secure Shell) is a protocol that provides encrypted remote access over networks.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SSH Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Port: TCP 22 β
β RFC: 4251-4256 β
β Version: SSH-2 (recommended), SSH-1 (deprecated) β
β β
β Features: β
β - Encrypted remote shell access β
β - File transfer (SCP, SFTP) β
β - Port forwarding/tunneling β
β - X11 forwarding β
β β
β Authentication methods: β
β - Password authentication β
β - Public key authentication (recommended) β
β - Host-based authentication β
β - Keyboard-interactive β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SSH Connection Process¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SSH Connection Process β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client] [Server] β
β β β β
β βββ(1) TCP connection (port 22) ββββββββΆ β β
β β β β
β βββ(2) Protocol version exchange ββββββββ β
β β SSH-2.0-OpenSSH_8.9 β β
β β β β
β ββββ(3) Key exchange algorithm negotiationββΆβ β
β β Encryption, MAC, compression β β
β β β β
β ββββ(4) Key exchange (DH/ECDH) ββββββββββΆβ β
β β Generate session key β β
β β β β
β ββββββ(5) Start encrypted communicationβββΆβ β
β β β β
β βββ(6) User authentication βββββββββββΆ β β
β β (password or public key) β β
β β β β
β βββ(7) Authentication success βββββββββββ β
β β β β
β ββββββ(8) Start shell session ββββββββββββΆβ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SSH Public Key Authentication¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SSH Public Key Authentication β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client] [Server] β
β β
β Private key (id_ed25519) Public key (authorized_keys) β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Never disclose β β Client public β β
β β Keep local only β β key stored β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β β β
β β β β
β Authentication process: β
β 1. Server sends random challenge β
β 2. Client signs challenge with private key β
β 3. Server verifies signature with public key β
β 4. Authentication succeeds if verification passes β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SSH Main Commands¶
# Basic connection
ssh user@hostname
ssh -p 2222 user@hostname # Specify port
# Generate keys
ssh-keygen -t ed25519 -C "email@example.com"
ssh-keygen -t rsa -b 4096
# Copy public key
ssh-copy-id user@hostname
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@hostname
# File transfer (SCP)
scp file.txt user@host:/path/
scp user@host:/path/file.txt ./
scp -r directory/ user@host:/path/
# SFTP
sftp user@hostname
SSH Tunneling¶
# Local port forwarding
# Local 8080 β via remote server β target server 80
ssh -L 8080:target.example.com:80 user@jump.example.com
# Remote port forwarding
# Remote server 8080 β local machine 80
ssh -R 8080:localhost:80 user@remote.example.com
# Dynamic port forwarding (SOCKS proxy)
ssh -D 1080 user@proxy.example.com
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SSH Local Port Forwarding β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ssh -L 8080:db.internal:3306 user@jump.example.com β
β β
β [Local PC] [Jump Server] [DB Server] β
β localhost:8080 jump.example.com db.internal:3306 β
β β β β β
β βββββ SSH Tunnel βββββΆβ β β
β β ββββββββββββββββββββΆβ β
β β β β β
β ββββββββββββββββββββββββββββββββββββββββββ β
β β
β Usage: mysql -h 127.0.0.1 -P 8080 (connect to DB locally) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
5. Telnet¶
Telnet Overview¶
Telnet provides terminal access to remote hosts. SSH is recommended for security.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Telnet Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Port: TCP 23 β
β RFC: 854 β
β β
β Features: β
β - Plaintext transmission (no encryption) β
β - Password exposure risk β
β - Vulnerable to sniffing β
β - Legacy systems only β
β β
β β οΈ Security Warning: β
β - Do NOT use Telnet on the Internet β
β - Replace with SSH β
β - Avoid even on internal networks β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Telnet Usage (Testing Only)¶
Telnet is unsuitable for remote access due to security, but useful for port connectivity testing.
# Port connectivity test
telnet example.com 80
telnet example.com 443
# HTTP test
telnet example.com 80
GET / HTTP/1.1
Host: example.com
(blank line)
# SMTP test
telnet mail.example.com 25
EHLO test
QUIT
# Connection check only (nc recommended)
nc -zv example.com 80
nc -zv example.com 22
Telnet vs SSH¶
| Feature | Telnet | SSH |
|---|---|---|
| Port | 23 | 22 |
| Encryption | None (plaintext) | Yes |
| Authentication | Plaintext password | Various methods |
| Security | Very vulnerable | Strong |
| File transfer | None | SCP, SFTP |
| Tunneling | None | Supported |
| Recommendation | Testing only | Always recommended |
6. WebSocket¶
WebSocket Overview¶
WebSocket is a protocol that provides bidirectional real-time communication between client and server.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β WebSocket Information β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Ports: TCP 80 (ws://), TCP 443 (wss://) β
β RFC: 6455 β
β β
β Features: β
β - Starts with HTTP upgrade β
β - Full-duplex bidirectional communication β
β - Persistent connection β
β - Low overhead (minimal headers) β
β - Real-time data transmission β
β β
β Use cases: β
β - Real-time chat β
β - Online gaming β
β - Stock/cryptocurrency prices β
β - Live streaming β
β - Collaboration tools β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
HTTP vs WebSocket¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HTTP vs WebSocket β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β HTTP (Request-Response) WebSocket (Bidirectional) β
β β
β Client Server Client Server β
β β β β β β
β βββRequest1ββΆβ βββConnectedββ β
β βββResponse1ββ β β β
β β β βββ Message ββ β
β βββRequest2ββΆβ βββ MessageββΆβ β
β βββResponse2ββ βββ Message ββ β
β β β βββ MessageββΆβ β
β βββRequest3ββΆβ β β β
β βββResponse3ββ βββ Message ββ β
β βββClosedβββββ β
β β
β Create connection each time Once connected, persistent β
β Only client can request Both sides can send β
β Request header overhead Minimal frame header β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
WebSocket Handshake¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β WebSocket Handshake β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Client Request - HTTP Upgrade] β
β βββββββββββββββββββββββββββββββββ β
β GET /chat HTTP/1.1 β
β Host: server.example.com β
β Upgrade: websocket β
β Connection: Upgrade β
β Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== β
β Sec-WebSocket-Version: 13 β
β β
β [Server Response - 101 Switching Protocols] β
β ββββββββββββββββββββββββββββββββββββββ β
β HTTP/1.1 101 Switching Protocols β
β Upgrade: websocket β
β Connection: Upgrade β
β Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= β
β β
β [Then communicate via WebSocket frames] β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
WebSocket Client (JavaScript)¶
// WebSocket connection
const socket = new WebSocket('wss://example.com/chat');
// Connection opened
socket.onopen = function(event) {
console.log('WebSocket connected');
socket.send('Hello Server!');
};
// Receive message
socket.onmessage = function(event) {
console.log('Message received:', event.data);
};
// Connection closed
socket.onclose = function(event) {
console.log('Connection closed:', event.code, event.reason);
};
// Error handling
socket.onerror = function(error) {
console.error('WebSocket error:', error);
};
// Send message
socket.send(JSON.stringify({ type: 'chat', message: 'Hello!' }));
// Close connection
socket.close();
WebSocket Server (Node.js)¶
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function(ws) {
console.log('Client connected');
// Receive message
ws.on('message', function(message) {
console.log('Received message:', message);
// Echo response
ws.send('Server response: ' + message);
// Broadcast to all clients
wss.clients.forEach(function(client) {
if (client.readyState === WebSocket.OPEN) {
client.send(message);
}
});
});
ws.on('close', function() {
console.log('Client connection closed');
});
});
7. Practice Problems¶
Basic Problems¶
- DHCP
- Explain each step of DORA.
-
List all information assigned by DHCP server.
-
FTP
- What's the difference between Active and Passive modes?
-
Explain FTP's security issues and alternatives.
-
Email
- Explain the roles of SMTP, POP3, and IMAP respectively.
- What's the difference between POP3 and IMAP?
Intermediate Problems¶
- SSH
- What are the advantages of SSH public key authentication?
-
Provide an example scenario for using SSH local port forwarding.
-
Port Numbers
-
Write the port numbers for these protocols:
- DHCP (client/server)
- FTP (control/data)
- SMTP (default/SSL)
- SSH
- POP3S
- IMAPS
-
Practical Problems
# Predict the results of these commands
# 1. Connect to remote DB via SSH tunnel
ssh -L 3306:db.internal:3306 user@bastion.example.com
mysql -h 127.0.0.1 -P 3306 -u dbuser -p
# 2. Upload file via SFTP
sftp user@server.example.com
put localfile.txt /home/user/
# 3. Test HTTP with Telnet
telnet example.com 80
GET / HTTP/1.1
Host: example.com
Advanced Problems¶
- WebSocket
- What's the difference between HTTP Polling and WebSocket?
-
Why does WebSocket handshake through HTTP?
-
Security Comparison
- Explain the security issues of Telnet, FTP, and SMTP.
- What are the secure alternatives for each?
8. Next Steps¶
In 15_Network_Security_Basics.md, let's learn about network security basics including firewalls, NAT, and VPNs!
9. References¶
RFC Documents¶
- RFC 2131 - DHCP
- RFC 959 - FTP
- RFC 5321 - SMTP
- RFC 1939 - POP3
- RFC 3501 - IMAP
- RFC 4251-4256 - SSH
- RFC 6455 - WebSocket
Port Number Summary¶
| Protocol | Plaintext Port | Secure Port |
|---|---|---|
| FTP | 21 (control), 20 (data) | 990 (FTPS) |
| SSH/SFTP | 22 | - |
| Telnet | 23 | - |
| SMTP | 25, 587 | 465 |
| DNS | 53 | 853 (DoT) |
| DHCP | 67/68 | - |
| HTTP | 80 | 443 (HTTPS) |
| POP3 | 110 | 995 |
| IMAP | 143 | 993 |