Common ports, protocols & DNS
Recognise common services by port and explain how DNS resolution works.
By Invicly Tech, , in Cyber Security Fundamentals. About 8 minutes to read.
In short
Services listen on well-known ports, so recognising a port suggests the protocol in use. DNS turns names into addresses through a chain of resolvers. Knowing the common ports and how DNS resolves is essential for reading scans and logs.
Explained simply
A computer can run many network services at once, like a web server and an email server. Ports are numbers that tell incoming traffic which service it is for. An IP address is like a building's street address, and a port is like the apartment number.
Some ports are well known. Web traffic uses 80 and 443. SSH remote login uses 22. Windows Remote Desktop uses 3389. When a defender sees traffic to port 3389 from the internet, they immediately think "someone is trying Remote Desktop".
DNS (Domain Name System) is the internet's phone book. People type names like example.com, but computers need IP addresses. DNS turns names into addresses. Because almost everything starts with a DNS lookup, DNS logs are one of the best places to spot malware calling home.
IP addresses are grouped into subnets. A subnet is a block of addresses that sit on the same network, written like 192.168.1.0/24. Knowing subnets tells you whether two machines are neighbours or whether traffic has to cross a router.
Press Play on a diagram to walk through it one step at a time.
- Client to Resolver: Where is example.com?1Where is example.com?
- Resolver to Root/TLD: Ask root then TLD2Ask root then TLD
- Root/TLD to Resolver: Try this authoritative server3Try this authoritative server
- Resolver to Authoritative: Where is example.com?4Where is example.com?
- Authoritative to Resolver: Here is the IP5Here is the IP
- Resolver to Client: Answer, cached with TTL6Answer, cached with TTL
- Remote access
- 22 SSH
- 23 Telnet (cleartext)
- 3389 RDP
- Web
- 80 HTTP
- 443 HTTPS
- Email
- 25 SMTP
- 143 IMAP
- 993 IMAPS
- Infrastructure
- 53 DNS
- 123 NTP
- 67/68 DHCP
- Windows and directory
- 445 SMB
- 389 LDAP
- 88 Kerberos
- Databases
- 3306 MySQL
- 5432 PostgreSQL
- 1433 MSSQL
In depth
Ports worth knowing by heart
Analysts recognise ports instantly the way drivers recognise road signs. The important ones are 20/21 FTP, 22 SSH, 23 Telnet, 25 SMTP, 53 DNS, 80 HTTP, 110 POP3, 123 NTP, 143 IMAP, 389 LDAP, 443 HTTPS, 445 SMB, 3306 MySQL, 3389 RDP and 5432 PostgreSQL.
Remember that a port number is a convention, not a guarantee. Attackers sometimes run their tools on port 443 to blend in with web traffic. A port tells you what to expect, and the traffic itself tells you what is really happening.
- 0-1023: well-known ports for system services
- 1024-49151: registered ports for apps
- 49152-65535: temporary client ports
Reading CIDR notation
CIDR notation writes a network as an address and a slash number, such as 10.20.0.0/16. The slash number says how many bits are fixed for the network. The rest are free for hosts. A /24 has 8 free bits, so 256 addresses (254 usable). A /16 has 65,536. A /32 is one single address.
Three ranges are private and never routed on the internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. If you see a private address coming from the internet side of a firewall, it is spoofed or misconfigured.
- 1/8
16,777,216 addresses, e.g. 10.0.0.0/8
- 2/16
65,536 addresses
- 3/24
256 addresses, 254 usable
- 4/32
One single address
DNS record types defenders meet
An A record maps a name to an IPv4 address and AAAA to IPv6. CNAME points one name to another. MX lists mail servers. TXT holds text, used for email security records like SPF and DMARC. PTR does reverse lookups from IP to name. NS lists the authoritative name servers.
In investigations, newly registered domains, very long random-looking subdomains and lots of TXT queries can all hint at malware or data being sneaked out through DNS.
Cleartext vs encrypted protocols
Older protocols send everything, including passwords, as plain readable text. Telnet, FTP, HTTP, POP3 and plain SMTP are examples. Anyone who can capture the traffic can read it. Modern replacements wrap the same job in encryption: SSH instead of Telnet, SFTP or FTPS instead of FTP, HTTPS instead of HTTP, IMAPS and POP3S for mail.
A quick audit question for any network is: which cleartext protocols are still in use, and why? Finding Telnet or FTP on a production network is a common, easy win.
- Telnet, port 23
- FTP, port 21
- HTTP, port 80
- POP3, port 110
- SSH, port 22
- SFTP (over SSH) or FTPS
- HTTPS, port 443
- POP3S 995, IMAPS 993
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Memorise key well-known ports~45m
- 2Explain IP addressing and subnets~45m
- 3Trace a DNS lookup step by step~45m
- 4Explain HTTP, SMTP, SSH and RDP basics~45m
Key points
- HTTP is 80, HTTPS 443, SSH 22, DNS 53, RDP 3389.
- The resolver walks root, TLD and authoritative servers.
- Answers are cached for the record's time to live.
- Subnets group addresses and shape routing.
Key terms
Tap a card to flip it. 0/4 known
Examples
Investigating a domain with dig
A user clicked a link to invoice-portal.example. Step 1: Look up the A record to find the server IP. Step 2: Look up NS records to see who hosts the DNS. Step 3: Check MX to see if it also receives mail. Step 4: Run a reverse lookup on the IP. Step 5: Search the domain in your DNS logs to see which other users looked it up. The lookups themselves are safe; they do not visit the site.
dig +short invoice-portal.example A
dig +short invoice-portal.example NS
dig +short invoice-portal.example MX
dig +short -x 203.0.113.50 # reverse lookup (PTR)
dig +short invoice-portal.example TXTIs this traffic local or routed?
A firewall log shows 192.168.10.45 talking to 192.168.12.8. Step 1: The network uses /24 subnets. Step 2: 192.168.10.45 is in 192.168.10.0/24 and 192.168.12.8 is in 192.168.12.0/24. Step 3: Different subnets, so traffic passed through a router or firewall, which is why it appears in this log at all. Step 4: If the network were a single /16, both would be local and the firewall would never see this traffic. Knowing the subnet layout tells you which logs can see which conversations.
Quick reference
- 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS, 445 SMB, 3389 RDP
- Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- /24 = 256 addresses, /16 = 65,536, /32 = one host
- dig +short name A | dig +short -x IP (forward and reverse DNS)
- DNS uses UDP 53 for most queries, TCP 53 for large answers and zone transfers
- Port numbers are hints, not proof; check the actual traffic
- SMB (445) and RDP (3389) should never face the internet directly
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
On your own computer, list which ports are listening. Name the service for any well-known port you see.
- Exercise 2medium
Use dig to query A, MX, TXT and NS records for a domain you own or a well-known public one. Identify the SPF record in the TXT results and explain what it says.
- Exercise 3hard
Given these subnets: users 10.10.0.0/22, servers 10.10.8.0/24, guests 10.10.20.0/24. Work out the address range of each and decide whether 10.10.3.77 and 10.10.8.200 are in the same subnet.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Can a service run on a non-standard port?
- Yes. Any service can listen on any port. Admins sometimes move SSH to another port to reduce noise, and attackers sometimes use 443 or 53 to blend in.
- Does changing the SSH port make it secure?
- It reduces automated noise in logs but is not real security. Key-based login, disabling root login and rate limiting are what actually protect SSH.
- What is DNS over HTTPS and why do defenders care?
- It sends DNS queries inside encrypted HTTPS, which protects privacy but hides lookups from network DNS logs. Companies often require their own resolver so they can still monitor DNS.