Sub topic 5
Common Protocols and the Ports They Use
This chapter assumes you know what a port number is and the difference between TCP and UDP, covered in the two previous chapters. Here you tie each well-known port to the protocol and service that uses it. You also learn which choices are secure, which are not, and which mistakes show up on the exam and on the job.
Grouping Protocols by Job
Memorizing a flat list of ports is slow. It is easier to sort protocols by what they do.
- File transfer: FTP, SFTP, TFTP, SMB
- Remote access: SSH, Telnet, RDP
- Email: SMTP, POP3, IMAP
- Web: HTTP, HTTPS
- Network services: DHCP, DNS, LDAP, SNMP, NetBIOS
Port Protocol Service
20/21 TCP FTP (data/control)
22 TCP SSH, SFTP
23 TCP Telnet
25 TCP SMTP
53 TCP/UDP DNS
67/68 UDP DHCP (server/client)
69 UDP TFTP
80 TCP HTTP
110 TCP POP3
137-139 TCP/UDP NetBIOS/NetBT
143 TCP IMAP
161/162 UDP SNMP (queries/traps)
389 TCP/UDP LDAP
443 TCP HTTPS
445 TCP SMB over TCP
3389 TCP/UDP RDPFile Transfer Protocols
FTP (File Transfer Protocol) moves files between a client and a server. It uses two TCP ports. Port 21 carries commands (the control channel), and port 20 carries the file data in active mode. FTP sends usernames, passwords, and data in clear text, so anyone who captures the traffic can read them.
SFTP (SSH File Transfer Protocol) transfers files inside an encrypted SSH session on TCP port 22. It is not FTP with a lock added. It is a different protocol that runs over SSH. Do not confuse it with FTPS, which is FTP wrapped in TLS and uses different ports.
TFTP (Trivial File Transfer Protocol) is a minimal protocol on UDP port 69. It has no login and no encryption. Devices use it to fetch boot images and configuration files, for example during network boot (PXE) or when loading firmware on a switch.
SMB (Server Message Block) shares files and printers on Windows networks. Modern systems run it directly over TCP port 445. Older systems ran it on top of NetBIOS.
Remote Access Protocols
SSH (Secure Shell) gives an encrypted command-line session on TCP port 22. It replaced Telnet.
Telnet provides the same kind of remote command line on TCP port 23, but in clear text. It should not be used on untrusted networks. If a question asks for a secure replacement for Telnet, the answer is SSH.
RDP (Remote Desktop Protocol) gives a full graphical desktop session on a Windows computer. It uses port 3389, mainly TCP, with UDP for better performance in newer versions.
Email Protocols
Email uses one protocol to send and another to retrieve.
- SMTP (Simple Mail Transfer Protocol) sends mail, on TCP port 25. It moves mail from a client to a server and between servers.
- POP3 (Post Office Protocol version 3) retrieves mail on TCP port 110. It usually downloads messages to one device and removes them from the server.
- IMAP (Internet Message Access Protocol) retrieves mail on TCP port 143. Messages stay on the server, so several devices see the same mailbox and folders.
Choose IMAP when a user reads mail on a phone and a laptop. Choose POP3 when mail should be stored on a single machine.
Web Protocols
HTTP (Hypertext Transfer Protocol) carries web pages on TCP port 80. HTTPS (HTTP Secure) is HTTP protected by TLS on TCP port 443. A browser's padlock icon indicates an HTTPS connection. Use HTTPS whenever a page asks for a password or payment details.
Network Service Protocols
- DHCP (Dynamic Host Configuration Protocol) hands out IP settings. The server listens on UDP 67 and the client uses UDP 68.
- DNS (Domain Name System) turns names into IP addresses on port 53. Ordinary queries use UDP. TCP is used for large responses and zone transfers.
- LDAP (Lightweight Directory Access Protocol) looks up information in a directory such as Active Directory, on port 389.
- SNMP (Simple Network Management Protocol) monitors and manages network devices. Managers query devices on UDP 161. Devices send unsolicited alerts, called traps, to UDP 162.
- NetBIOS/NetBT is an older Windows naming and session service on ports 137 to 139.
How Ports Fit Into a Connection
A server listens on a well-known port. The client picks a random high port as its source. For example, a browser might connect from port 52114 to port 443 on a web server.
The destination port tells the server which service should receive the traffic. This is why a firewall rule can allow web traffic while blocking Telnet on the same host.
Secure Versus Insecure Pairs
The exam often asks you to replace an insecure protocol with a secure one.
| Insecure | Port | Secure replacement | Port |
|---|---|---|---|
| Telnet | 23 | SSH | 22 |
| HTTP | 80 | HTTPS | 443 |
| FTP | 20/21 | SFTP | 22 |
Other protocols have secure forms too. Encrypted versions of SMTP, POP3, and IMAP exist (commonly 465 or 587 for SMTP, 995 for POP3, and 993 for IMAP). The A+ exam focuses mostly on the table above and the standard ports.
Verifying Ports on a Computer
You can see which ports a Windows computer is listening on and using. The netstat command lists connections and listening ports.
netstat -anLook for LISTENING entries. A line such as 0.0.0.0:3389 LISTENING shows that the computer accepts RDP connections. If you did not intend to allow remote desktop, that is a finding to fix.
Common Errors and Edge Cases
- Mixing up SMTP and POP3/IMAP. SMTP only sends. A user who can receive mail but not send it has a problem with SMTP (port 25 or its secure variant), not POP3 or IMAP.
- Treating SFTP as FTP. SFTP uses port 22, not 20 or 21. A firewall that allows only 21 will not pass SFTP.
- Forgetting DHCP uses two ports. The server uses 67 and the client uses 68, both UDP.
- Assuming DNS is only UDP. It uses both. Blocking TCP 53 can break large lookups.
- Port numbers can be changed. An administrator can run SSH on port 2222. The well-known numbers are defaults, not rules.
- A blocked port looks like a dead server. If a web page does not load but the server answers
ping, a firewall may be blocking 80 or 443. Ping uses ICMP, which has no port.
Practice
Exercise
A technician must replace Telnet with a secure alternative. Which protocol and port should be used?
Show answer
SSH on TCP port 22. It provides the same remote command line, but encrypted.
Exercise
A user can read incoming email on a phone and a laptop, and the messages appear on both. Which retrieval protocol is most likely in use, and on what port?
Show answer
IMAP, on TCP port 143. IMAP keeps messages on the server, so every device sees the same mailbox.
Exercise
A client can ping a web server but cannot load its secure website. Which port should you check on the firewall first?
Show answer
TCP port 443, used by HTTPS. Ping uses ICMP and has no port, so it can succeed while port 443 is blocked.
Exercise
Match each service to its port: DHCP server, SNMP trap, RDP, SMB over TCP.
Show answer
DHCP server is UDP 67. An SNMP trap goes to UDP 162. RDP is port 3389. SMB over TCP is port 445.