Sub topic 11
Common ports and protocols
This chapter assumes you know what an IP address is and how a router moves traffic between a LAN and the internet. It also assumes you can run commands in a terminal. The goal is to match a protocol to its port number and to know when a port matters in practice.
What a port is
An IP address identifies a device. A port is a number from 0 to 65535 that identifies a service on that device. A protocol is the set of rules two programs follow when they talk. When your browser requests a web page, the packet goes to the server's IP address and to a port, usually 443. The server's operating system hands the data to the program listening on that port.
Ports fall into three ranges:
| Range | Name | Use |
|---|---|---|
| 0 to 1023 | Well-known ports | Standard services such as HTTP and SSH |
| 1024 to 49151 | Registered ports | Applications registered with IANA |
| 49152 to 65535 | Dynamic (ephemeral) ports | Temporary source ports chosen by the client |
The ephemeral range is why a client's side of a connection uses a random high port while the server side uses a fixed one.
TCP and UDP
Two transport protocols carry most traffic.
- TCP (Transmission Control Protocol) is connection-oriented. It sets up a session with a three-way handshake, numbers the data, and retransmits anything lost. Use it when every byte must arrive correctly, as with web pages, email, and file transfer.
- UDP (User Datagram Protocol) is connectionless. It sends datagrams with no handshake and no retransmission. It has less overhead and suits traffic where speed matters more than perfection, such as DNS lookups, DHCP, streaming, and voice.
Ports to memorize for Core 1
The exam expects you to recognize these by number and by name.
| Port | Protocol | Transport | Purpose |
|---|---|---|---|
| 20, 21 | FTP | TCP | File transfer. 21 carries commands, 20 carries data in active mode. |
| 22 | SSH | TCP | Encrypted remote shell. Also used by SFTP and SCP. |
| 23 | Telnet | TCP | Unencrypted remote shell. Avoid it. |
| 25 | SMTP | TCP | Sending email between servers |
| 53 | DNS | UDP and TCP | Name resolution |
| 67, 68 | DHCP | UDP | 67 is the server, 68 is the client |
| 69 | TFTP | UDP | Simple file transfer with no authentication |
| 80 | HTTP | TCP | Unencrypted web traffic |
| 110 | POP3 | TCP | Downloading email |
| 137 to 139 | NetBIOS/NetBT | TCP and UDP | Legacy Windows name and file services |
| 143 | IMAP | TCP | Reading email kept on the server |
| 161 | SNMP | UDP | Monitoring network devices |
| 389 | LDAP | TCP | Directory lookups |
| 443 | HTTPS | TCP | Web traffic encrypted with TLS |
| 445 | SMB/CIFS | TCP | Windows file and printer sharing |
| 3389 | RDP | TCP | Windows Remote Desktop |
Some other services are worth knowing. SLP uses port 427 and AFP uses port 548. Secure mail variants include 587 (SMTP submission with TLS), 993 (IMAP over TLS), and 995 (POP3 over TLS).
Secure and insecure pairs
Many protocols have a plaintext version and an encrypted replacement. Pairing them helps you remember both.
- Telnet (23) is replaced by SSH (22).
- HTTP (80) is replaced by HTTPS (443).
- FTP (21) is replaced by SFTP, which runs over SSH on port 22. FTPS is a different protocol that adds TLS to FTP.
- LDAP (389) is replaced by LDAPS (636).
Plaintext protocols send usernames, passwords, and content in readable form. Anyone who can capture the traffic, for example on an open Wi-Fi network, can read it. On the exam, a scenario that asks for secure remote administration points to SSH, not Telnet.
Ports in SOHO router work
Ports connect directly to the router tasks later in this tutorial:
- Port forwarding sends traffic that arrives at the router's public address on a chosen port to a specific device on the LAN. Forwarding TCP 3389 to a PC exposes Remote Desktop to the internet. Forwarding TCP 443 to a home server exposes a web service.
- Firewall rules allow or block traffic by port, protocol, and direction. Blocking inbound 445 and 23 is a common baseline.
- Port triggering opens an inbound port temporarily after the router sees outbound traffic on another port. It is less specific than forwarding but does not need a fixed internal address.
The forwarded device should have a DHCP reservation, so its address does not change and break the rule.
Checking ports from a Windows PC
You can see what your computer is listening on and test whether a remote port is reachable.
netstat -ano | findstr LISTENING
Test-NetConnection -ComputerName example.com -Port 443The first command lists listening ports and the process ID that owns each. The second reports whether a TCP connection to port 443 succeeded. A TcpTestSucceeded : True line means the port is open end to end. If it is False while ping works, a firewall or a stopped service is blocking that port.
Common errors
- Confusing the client and server ports. The server listens on the well-known port. The client picks an ephemeral port. Firewall rules are written for the server port.
- Assuming a service is down when the port is blocked. Test with
Test-NetConnectionbefore restarting anything. - Mixing up POP3 and IMAP. POP3 usually downloads mail to one device. IMAP keeps mail on the server and syncs several devices.
- Forgetting that DNS uses both UDP and TCP. Normal lookups use UDP 53. Large responses and zone transfers use TCP 53.
- Mixing up SFTP and FTPS. SFTP is SSH-based on port 22. FTPS is FTP with TLS.
Exercise
A user can ping a mail server by name but cannot send email, and a test to the server's SMTP port fails. Which port is being tested, which transport protocol does it use, and what does the result suggest?
Show answer
SMTP uses TCP port 25. Because ping succeeds, name resolution and basic connectivity work. The failed port test suggests a firewall or ISP is blocking port 25 or the mail service is not listening. Some ISPs block outbound 25, so trying the submission port 587 is a reasonable next step.
Exercise
You need to give a technician secure command-line access to a small-office server, and the current setup uses port 23. Which protocol and port should replace it, and why?
Show answer
Use SSH on TCP port 22. Telnet on port 23 sends everything, including passwords, in plaintext. SSH encrypts the session.