Networking Fundamentals 6 min read · Last verified 2026-11-25

Essential Network Ports & Protocols Study Guide: TCP vs. UDP, Stateful Firewalls & Real Scenarios

Memorizing a flat alphabetical list of 40 port numbers is the hardest way to learn networking. Engineers remember ports effortlessly by grouping them into operational workflows—remote access, name resolution, web & TLS, email delivery, VPN tunneling, and cloud datastores—and pairing each port with whether it needs TCP reliability or low-overhead UDP.

Primary References: IANA Service Name & Transport Protocol Port Registry, RFC 6335 · Author: NetDevKit Engineering Team

1. Understanding the Three IANA Port Ranges (0–65,535)

B

o

t

h

T

C

P

a

n

d

U

D

P

h

e

a

d

e

r

s

c

a

r

r

y

a

1

6

-

b

i

t

s

o

u

r

c

e

p

o

r

t

a

n

d

1

6

-

b

i

t

d

e

s

t

i

n

a

t

i

o

n

p

o

r

t

(

0

t

h

r

o

u

g

h

6

5

,

5

3

5

)

.

R

F

C

6

3

3

5

d

i

v

i

d

e

s

t

h

a

t

s

p

a

c

e

i

n

t

o

t

h

r

e

e

t

i

e

r

s

:

W

e

l

l

-

K

n

o

w

n

S

y

s

t

e

m

P

o

r

t

s

(

0

–

1

0

2

3

,

h

i

s

t

o

r

i

c

a

l

l

y

r

e

q

u

i

r

i

n

g

r

o

o

t

/

C

A

P

_

N

E

T

_

B

I

N

D

_

S

E

R

V

I

C

E

o

n

U

n

i

x

h

o

s

t

s

)

,

R

e

g

i

s

t

e

r

e

d

U

s

e

r

P

o

r

t

s

(

1

0

2

4

–

4

9

1

5

1

,

a

s

s

i

g

n

e

d

t

o

d

a

t

a

b

a

s

e

s

,

V

P

N

s

,

a

n

d

a

p

p

l

i

c

a

t

i

o

n

s

e

r

v

i

c

e

s

l

i

k

e

3

3

0

6

M

y

S

Q

L

,

5

4

3

2

P

o

s

t

g

r

e

S

Q

L

,

a

n

d

6

4

4

3

K

u

b

e

r

n

e

t

e

s

A

P

I

)

,

a

n

d

D

y

n

a

m

i

c

/

E

p

h

e

m

e

r

a

l

P

o

r

t

s

(

4

9

1

5

2

–

6

5

5

3

5

,

p

i

c

k

e

d

t

e

m

p

o

r

a

r

i

l

y

b

y

c

l

i

e

n

t

o

p

e

r

a

t

i

n

g

s

y

s

t

e

m

s

f

o

r

o

u

t

b

o

u

n

d

c

o

n

n

e

c

t

i

o

n

s

)

.

Port(s) Transport Protocol / Service Operational Role & Firewall Tip
22 TCP SSH / SFTP Encrypted remote shell; restrict to bastion CIDR + rate limit
53 UDP & TCP DNS UDP for standard queries; TCP for zone transfers & large DNSSEC replies
67 / 68 UDP DHCP Server listens on 67, client on 68; LAN broadcast only
80 / 443 TCP (443 +UDP) HTTP / HTTPS & QUIC Web traffic; HTTP/3 QUIC uses UDP/443 alongside TCP/443
123 UDP NTP Clock sync critical for TLS, Kerberos & JWT exp checks
161 / 162 UDP SNMP / Traps 161 polling, 162 async alerts; never expose to 0.0.0.0/0
179 TCP BGP Autonomous system peering; pair with TCP-AO/MD5 & GTSM TTL
389 / 636 TCP LDAP / LDAPS Directory auth; block plaintext 389 outside private LAN
500 / 4500 UDP IPsec IKE / NAT-T 500 negotiates Phase 1; 4500 encapsulates ESP across NAT
51820 UDP WireGuard VPN Silent drop for unauthenticated packets (stealth by default)

2. Classic Dual-Protocol & Asymmetric Port Questions

Four port behaviors appear constantly on both exams and real troubleshooting tickets. First, DNS uses UDP/53 for fast single-packet queries, but falls back to TCP/53 whenever responses exceed DNS payload limits (common with DNSSEC keys) or during AXFR zone transfers—blocking TCP/53 causes mysterious intermittent resolution failures.

Second, modern HTTPS runs over TCP/443 for HTTP/1.1 and HTTP/2, AND UDP/443 for HTTP/3 (QUIC). Third, IPsec VPNs negotiate over UDP/500 but switch to UDP/4500 (NAT Traversal) the instant NAT is detected along the path. Fourth, email submission from mail clients uses TCP/587 (STARTTLS) or 465 (implicit TLS), while server-to-server relay stays on TCP/25.

3. Stateful Firewalls vs. Stateless ACLs: Why Return Ports Work

B

e

g

i

n

n

e

r

s

f

r

e

q

u

e

n

t

l

y

a

s

k

:

'

I

f

m

y

c

l

i

e

n

t

c

o

n

n

e

c

t

s

f

r

o

m

e

p

h

e

m

e

r

a

l

p

o

r

t

5

3

4

1

2

t

o

w

e

b

s

e

r

v

e

r

p

o

r

t

4

4

3

,

w

h

y

d

o

n

'

t

I

h

a

v

e

t

o

o

p

e

n

p

o

r

t

5

3

4

1

2

i

n

b

o

u

n

d

?

'

O

n

a

s

t

a

t

e

f

u

l

f

i

r

e

w

a

l

l

(

L

i

n

u

x

n

f

t

a

b

l

e

s

c

o

n

n

t

r

a

c

k

,

U

F

W

,

o

r

A

W

S

S

e

c

u

r

i

t

y

G

r

o

u

p

s

)

,

t

h

e

f

i

r

e

w

a

l

l

r

e

c

o

r

d

s

t

h

e

o

u

t

b

o

u

n

d

f

l

o

w

i

n

i

t

s

s

t

a

t

e

t

a

b

l

e

a

n

d

a

u

t

o

m

a

t

i

c

a

l

l

y

p

e

r

m

i

t

s

m

a

t

c

h

i

n

g

r

e

t

u

r

n

p

a

c

k

e

t

s

.

O

n

a

s

t

a

t

e

l

e

s

s

f

i

l

t

e

r

(

l

i

k

e

A

W

S

N

e

t

w

o

r

k

A

C

L

s

o

r

c

l

a

s

s

i

c

C

i

s

c

o

r

o

u

t

e

r

A

C

L

s

)

,

y

o

u

m

u

s

t

e

x

p

l

i

c

i

t

l

y

p

e

r

m

i

t

i

n

b

o

u

n

d

r

e

t

u

r

n

t

r

a

f

f

i

c

t

o

t

h

e

e

p

h

e

m

e

r

a

l

p

o

r

t

r

a

n

g

e

(

1

0

2

4

–

6

5

5

3

5

)

.

Companion Offline NetDevKit Calculators

Apply the formulas from this guide immediately in your browser with zero server uploads:

Frequently Asked Questions

Why does DNS require both UDP 53 and TCP 53?

Standard short DNS lookups use UDP 53 for minimal latency, while zone transfers (AXFR/IXFR) and oversized responses—especially DNSSEC-signed records—automatically retry over TCP 53.

What is the difference between SSH (22), Telnet (23), and RDP (3389)?

SSH (TCP 22) provides encrypted command-line access, Telnet (TCP 23) sends credentials in plaintext and should be disabled in production, and RDP (TCP/UDP 3389) provides graphical Windows remote desktop sessions.

Which ports should NEVER be exposed to 0.0.0.0/0 on cloud servers?

Management and datastore ports—especially Redis (6379), MongoDB (27017), PostgreSQL (5432), MySQL (3306), SMB (445), SNMP (161), and unrestricted RDP (3389)—should always be restricted to private VPC or VPN CIDRs.

More Engineering Guides

Copied to clipboard