appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

Ports, TCP and UDP

Lesson 3 of 38 minBeginner

How one address serves many services.

An IP address finds the machine. A port (0 to 65535) finds the service on it. A full connection is identified by address and port: 203.0.113.5:443.

PortService
22SSH
25SMTP (mail between servers)
53DNS
80HTTP
443HTTPS
3306MySQL
5432PostgreSQL

TCP vs UDP

  • TCP: connection-oriented, reliable, ordered. Used by web, email, SSH.
  • UDP: no connection and no delivery guarantee, but very low overhead. Used by DNS queries, video calls, games and QUIC (HTTP/3).

Firewalls

A firewall allows or blocks traffic by address, port and protocol. The safe default is to deny everything and open only the ports you need.

Test a connection

ping example.com                 # is the host reachable?
nc -zv example.com 443           # is port 443 open?
ss -tlnp                         # which ports is this machine listening on? (Linux)
traceroute example.com           # path packets take

NoteSome hosts do not answer ping on purpose, so a failed ping does not always mean the host is down.

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

1. Which port does HTTPS use by default?
2. Which protocol is used for DNS queries, usually?
Hintping and the host.
4. What is the safest firewall default?

Key terms