Ports and Protocols
Firewall rules, logs and network analysis all depend on recognising ports and protocols. This lesson explains port ranges, the commonly used ports and protocols, and which protocols are insecure and what replaces them.
Learning outcomes
After completing this lesson, you will be able to:
- Describe port ranges and sockets.
- Identify commonly used ports and protocols.
- Identify insecure protocols and their secure replacements.
- Interpret listening ports on a host.
Ports and sockets
A port is a 16-bit number (0 to 65,535) that identifies a service or connection endpoint on a host, used by TCP and UDP. A socket is the combination of an IP address, protocol and port, such as 192.0.2.10 TCP 443; a connection is identified by the source and destination sockets. Port numbers are divided into ranges.
| Range | Name | Use |
|---|---|---|
| 0 to 1023 | Well-known (system) ports | Standard services such as HTTP and SSH; usually require administrative rights to bind |
| 1024 to 49151 | Registered ports | Services registered with IANA, such as SQL Server and RDP |
| 49152 to 65535 | Dynamic (ephemeral) ports | Temporary client-side ports for outgoing connections |
Services can run on non-standard ports, so a port number suggests but does not prove what protocol is in use; next-generation firewalls identify applications by their traffic rather than only their ports.
Commonly used ports and protocols
SSCP candidates are expected to recognise common ports. The following table lists them with their security notes.
| Port | Protocol | Purpose | Security note |
|---|---|---|---|
| 20, 21 TCP | FTP | File transfer (data, control) | Cleartext; replace with SFTP or FTPS |
| 22 TCP | SSH, SFTP, SCP | Secure remote shell and file transfer | Secure; restrict and use keys |
| 23 TCP | Telnet | Remote terminal | Cleartext; replace with SSH |
| 25 TCP | SMTP | Mail transfer between servers | Use STARTTLS; 587 for client submission |
| 49 TCP | TACACS+ | Device administration AAA | Encrypts full payload |
| 53 TCP/UDP | DNS | Name resolution | Abused for tunnelling and amplification; use DNSSEC |
| 67, 68 UDP | DHCP | Address assignment | Rogue DHCP servers; use DHCP snooping |
| 69 UDP | TFTP | Trivial file transfer | No authentication; restrict tightly |
| 80 TCP | HTTP | Web | Cleartext; redirect to HTTPS |
| 88 TCP/UDP | Kerberos | Authentication | Requires synchronised time |
| 110, 995 TCP | POP3, POP3S | Mail retrieval | Use 995 (TLS) |
| 123 UDP | NTP | Time synchronisation | Essential for logs; abused for amplification |
| 143, 993 TCP | IMAP, IMAPS | Mail retrieval | Use 993 (TLS) |
| 161, 162 UDP | SNMP | Device monitoring and traps | Use SNMPv3; v1 and v2c use cleartext community strings |
| 389, 636 TCP | LDAP, LDAPS | Directory access | Use LDAPS or StartTLS |
| 443 TCP | HTTPS | Secure web | TLS 1.2 or 1.3 |
| 445 TCP | SMB | Windows file sharing | Never expose to the internet |
| 514 UDP | Syslog | Log transfer | Cleartext; use TLS on 6514 |
| 1433 TCP | Microsoft SQL Server | Database | Do not expose externally |
| 1812, 1813 UDP | RADIUS | Authentication and accounting | Protect shared secrets |
| 3389 TCP | RDP | Remote desktop | Never expose directly; use VPN or gateway with MFA |
Common ports
Insecure protocols and their replacements
Many older protocols send credentials and data in cleartext, so anyone who can capture the traffic can read them. Practitioners replace them with secure equivalents, as the following comparison summarises.
Beyond replacing protocols, practitioners close ports that are not needed, restrict administrative protocols such as SSH and RDP to management networks or VPNs, and never expose services such as SMB, RDP and database ports directly to the internet, where they are scanned constantly.
The following diagram assesses each of three inbound firewall rules from the internet.

Secure replacements
Seeing ports on a host
On Linux, the ss command lists listening sockets and the processes that own them, which helps confirm that only expected services are exposed.
ss -tulpnEach line shows the protocol (tcp or udp), the local address and port (0.0.0.0 or [::] means all interfaces, 127.0.0.1 means local only) and the owning process. A database listening on all interfaces when it should listen only locally is a common finding. The lab for the network security appliances module uses this command.
Reviewing a firewall
A review of an internet-facing firewall finds inbound rules allowing TCP 443 to the web server, TCP 3389 to a file server and UDP 161 to the core router. Which rules are problems?
TCP 443 to the web server is expected. TCP 3389 exposes RDP to the internet, a major target for brute force and exploits; remote administration should go through a VPN or remote desktop gateway with MFA. UDP 161 exposes SNMP on the router, which can leak configuration and, with v1/v2c, uses cleartext community strings; management should be restricted to an internal management network. Both rules should be removed.
Identifying cleartext traffic
A packet capture on the server network shows administrators logging in to switches over TCP 23 and a backup job sending files over TCP 21. What should be recommended?
Port 23 is Telnet and 21 is FTP, both cleartext, so the capture reveals switch passwords and backup contents. Replace Telnet with SSH on the switches (and disable Telnet), and move the backup to SFTP or another encrypted transfer. Rotate the exposed switch credentials.
Which port and protocol should replace SNMPv2c on port 161 for secure monitoring?
Show answer
SNMPv3 on the same port, which adds user authentication and encryption.
Exam Tips
Remember for the exam
- Well-known ports are 0 to 1023; dynamic ports are 49152 to 65535.
- Replace Telnet with SSH, FTP with SFTP or FTPS, SNMPv1/v2c with SNMPv3.
- Never expose RDP, SMB or database ports directly to the internet.