Secure Network Best Practices Library · Firewalls and VPN

TCP and UDP ports reference guide: common network ports and how to secure them

A plain-language reference to the TCP and UDP ports that business networks use every day: remote access, web, mail, file sharing, name and address services, VPN, voice and databases. For each one it says what the port does and where it belongs: open to the internet, inside only, or nowhere.

Prefer to have it done for you? IT Perfection provides network security hardening and managed firewall services for companies in Irvine, Orange County and Los Angeles County.

Ali Hassani, CISSP and Certified CISO, IT PerfectionWritten by Ali Hassani, CISSP and C|CISO · 25+ years designing, securing and supporting business networks · Updated November 2026

Network engineer working on a laptop beside a server rack
ScanWe list the ports that answer on your public addresses and inside.

Secure Network Best Practices Library › Firewalls and VPN › TCP and UDP ports reference

What it isA port is a number from 1 to 65535 that identifies one service on a device. TCP and UDP are the two transport protocols that use ports. Firewall rules are written in terms of addresses and ports.
Where it livesIn every firewall rule, forwarding rule and access list
Works onAll networks. Port numbers are assigned by IANA and are the same for every vendor
Cost and timeNothing; this is a reference
Risk if missingExposed servicesA port open to the internet puts the service behind it within reach of everyone

The basics

What a port is and why it matters for security

An IP address gets traffic to the right device. The port number gets it to the right program on that device. A web server listens on port 443, a file server on 445, a remote desktop host on 3389. When nothing is listening on a port, connections to it are refused.

TCP sets up a connection and confirms delivery; it is used for web, email, file sharing and remote access. UDP sends without setting up a connection; it is used where speed matters more than confirmation, such as name lookups, voice and video.

Security work on a network is, to a large extent, deciding which ports on which devices can be reached from where. Every port that answers is a service someone has to keep patched and configured. The fewer that answer, and the fewer places they answer to, the smaller the job.

First rule

Ports that should never face the internet

PortServiceWhyUse instead
TCP 3389Remote Desktop (RDP)Constant password guessing; a direct path to a computerVPN with multi-factor sign-in
TCP 445, 139Windows file sharing (SMB, NetBIOS)Designed for local networksVPN, or a cloud file service
TCP 23TelnetEverything in clear text, including passwordsSSH, inside only
TCP 21FTPClear-text sign-inSFTP or HTTPS upload, limited by source
TCP 1433, 3306, 5432, 1521Databases (SQL Server, MySQL, PostgreSQL, Oracle)Data and credentials directly exposedVPN or private application connection
TCP 5900VNCRemote control with weak protectionVPN
UDP 161SNMPReveals device details; old versions have no real protectionInside only, version 3
TCP 135, UDP 137-138Windows RPC and NetBIOSLocal network servicesNever forwarded
TCP 80, 443, 8080, 8443 on device admin pagesFirewall, switch, printer, camera and recorder managementWhoever signs in controls the deviceManagement network and VPN

Moving one of these to a different port number does not protect it. Scanners test all ports. See NAT and port forwarding security and management interface lockdown.

Reference

Common TCP and UDP ports, what they do, and where they belong

Remote access and administration

PortProtocolServiceWhere it belongs
22TCPSSH: encrypted command line and file transfer (SFTP)Inside, from the admin range; internet only with a source limit
23TCPTelnetNowhere
3389TCP, UDPRemote DesktopInside; from outside only through the VPN
5985, 5986TCPWindows remote managementInside, admin range
161, 162UDPSNMP queries and trapsInside, monitoring server only

Web and file transfer

PortProtocolServiceWhere it belongs
80TCPHTTP: unencrypted webOutbound; inbound only to redirect to 443
443TCP, UDPHTTPS: encrypted web; UDP for HTTP/3Outbound; inbound to published web services
21TCPFTP controlAvoid; replace with SFTP
445TCPSMB: Windows file and printer sharingInside, staff to file servers
2049TCP, UDPNFS file sharingInside, servers only

Email

PortProtocolServiceWhere it belongs
25TCPSMTP between mail serversTo and from your mail service only
587TCPMail submission from clients, with sign-inOutbound to your mail provider
993TCPIMAP over TLSOutbound to your mail provider
995TCPPOP3 over TLSOutbound to your mail provider
110, 143TCPPOP3 and IMAP without encryptionAvoid

Names, addresses and time

PortProtocolServiceWhere it belongs
53UDP, TCPDNS: name lookupsClients to your resolvers; resolvers outbound
67, 68UDPDHCP: address assignmentInside each VLAN, or relayed
123UDPNTP: timeInside to your time source; that source outbound
88TCP, UDPKerberos: Windows sign-inInside, to domain controllers
389, 636TCPLDAP and LDAP over TLS: directoryInside, to domain controllers; prefer 636
1812, 1813UDPRADIUS: authentication and accountingNetwork devices to the RADIUS server

VPN and voice

PortProtocolServiceWhere it belongs
500, 4500UDPIPsec key exchange and NAT traversalInternet to the VPN gateway, known peers where possible
1194UDPOpenVPNInternet to the VPN gateway
51820UDPWireGuard, common defaultInternet to the VPN gateway
5060, 5061UDP, TCPSIP call signalling; 5061 is encryptedTo and from your phone provider only
10000-20000 (varies)UDPRTP voice audioAs your phone provider specifies

Databases and printing

PortProtocolServiceWhere it belongs
1433TCPMicrosoft SQL ServerInside, application servers only
3306TCPMySQL and MariaDBInside, application servers only
5432TCPPostgreSQLInside, application servers only
9100TCPDirect printingInside, staff to printers
631TCPInternet Printing ProtocolInside, staff to printers
514UDPSyslogInside, devices to the log server

Port ranges for voice audio and for some applications differ by vendor; use the figures your provider publishes. The authoritative list of assigned port numbers is the IANA service name and port number registry.

Port ranges, and the port a connection comes from

RangeNameUsed for
0 to 1023Well-known portsStandard services such as web, mail, DNS and SSH
1024 to 49151Registered portsApplications registered with IANA, such as SQL Server on 1433 and Remote Desktop on 3389
49152 to 65535Dynamic or ephemeral portsChosen temporarily by the computer that starts a connection

Every connection has two ports. The destination port identifies the service, for example 443. The source port is picked at random from the dynamic range by the computer that starts the connection, and exists only for that conversation. This is why firewall rules are written against the destination port and leave the source port as any.

Business firewalls are stateful. When a rule allows a connection out, the firewall remembers it and lets the replies back in automatically. You do not open inbound ports for staff to browse the web. Inbound rules are needed only for connections that start from outside, which is exactly why each one deserves scrutiny.

Open, closed and filtered

StateWhat a scan seesMeaning
OpenThe port answersA service is listening and reachable from where you scanned
ClosedThe device refuses the connectionThe device is reachable, but nothing listens on that port
FilteredNo answer at allA firewall is dropping the traffic; this is the result you want for everything not deliberately published

The result depends on where the scan is run from. A port can be open from the staff network, filtered from the guest network and filtered from the internet, all at once. A complete review looks from each of those places.

Outbound ports matter too

Most attention goes to inbound ports, but what may leave the network is also a control. Malware on a computer has to reach its operator, and data has to leave to be stolen. An outbound policy that allows web, mail to your provider, DNS only to your chosen resolvers and the specific ports your applications need, and blocks the rest, removes many of the easy routes. Outbound file sharing (445), remote desktop (3389), Telnet (23) and mail on port 25 from ordinary computers are common candidates to block; none of them has a normal business use toward the internet from a staff computer.

How to check

How to see which ports are open

# Which ports this computer is listening on, and which program owns each
Get-NetTCPConnection -State Listen | Sort-Object LocalPort |
  Select-Object LocalAddress, LocalPort, OwningProcess
# Is a port on another device reachable from here?
Test-NetConnection 10.10.50.10 -Port 445

Scan only what is yours. Scanning addresses you do not own or have no written permission to test can breach law and provider terms. Confirm your public addresses with your internet provider before you start.

Step by step

A port review in six steps

  1. Inventory what is exposed

    Scan every public address from outside. Export the forwarding and inbound rules.

  2. Match each port to an owner

    Service, device, person, reason. No owner means the rule is disabled first.

  3. Move remote access behind a VPN

    Remote desktop, file sharing and management pages. See remote access VPN and MFA.

  4. Restrict what must stay open

    Limit by source address, and apply intrusion prevention to the rule.

  5. Segment internally

    The same thinking applies inside: staff do not need database ports; guests need nothing internal. See inter-VLAN routing and ACLs.

  6. Document and schedule the next review

    Keep the scan results. Repeat each quarter and after firewall changes.

A good review produces three things: a list of every port open to the internet with its owner and reason, a list of what was closed, and a dated scan that proves the result.

Common mistakes

Port and firewall mistakes we see most often

MistakeWhy it mattersFix
RDP published to the internetDirect path to a computer insideRemove; use the VPN.
Any-to-any rulesNo port is really controlledSpecific rules. See rule base clean-up.
Device admin pages on the WANControl of the device is exposedManagement network and VPN.
Flat internal networkEvery port on every device is reachable by everyone insideVLANs and rules between them.
Clear-text protocols still in usePasswords cross the network readableReplace Telnet, FTP, HTTP, plain LDAP.
No record of why a port is openNobody dares close itOwner, reason and review date on every rule.

Sources read Nov 22, 2026: IANA, Service Name and Transport Protocol Port Number Registry; NSA, Network Infrastructure Security Guide; Nmap reference guide.

Have us do it

Prefer to hand this off?

A port review is part of our network security hardening and managed firewall work. We scan your public addresses, match every open port to a service and an owner, move remote access behind the VPN, restrict what remains and give you the before and after results. You receive a written scope and a written quote before any work starts.

Ali Hassani, CISSP and Certified CISO, IT Perfection

Who does the work

Written by Ali Hassani, CISSP, C|CISO

Ali Hassani has 25+ years of hands-on experience in IT operations, cybersecurity, Microsoft infrastructure, network security and Azure, and works with businesses in Irvine, Orange County and Los Angeles County. Design, implementation and troubleshooting work is planned and reviewed by Ali personally.

This guide is for education and planning. It does not replace a professional audit, compliance assessment or vendor engineering review. Updated November 2026.

ISC2 CISSP badgeEC-Council Certified CISO (C|CISO) badgeCisco CCNP Routing and Switching badgeMCSE: Server Infrastructure badgeMicrosoft MCSE badgeMCSA: Security badgeCisco CCNA Cybersecurity badgeMCITP badge

FAQ

Common questions about network ports

What is the difference between TCP and UDP?

TCP sets up a connection and confirms that data arrived, which suits web, email and file transfer. UDP sends without a connection, which suits name lookups, voice and video where speed matters more.

Which ports should be closed on a firewall?

Inbound from the internet, everything that is not a deliberately published service. In particular remote desktop (3389), file sharing (445), Telnet (23), database ports and device management pages should never be open to the internet.

Is it safe to open port 3389?

Not to the internet. Remote desktop should be reached through a VPN with multi-factor sign-in. Changing the port number does not make it safe.

What is port 443 used for?

HTTPS, the encrypted web. Most cloud applications use it, which is why outbound 443 is allowed almost everywhere.

How can I check which ports are open on my network?

From inside, list the listening ports on each computer. From outside, scan your own public addresses with a tool such as nmap. Only scan addresses you own or have permission to test.

Can IT Perfection do this for us?

Yes. It is part of our network security hardening and managed firewall services for companies in Irvine, Orange County and Los Angeles County. Call 949-777-5567 or use the contact page to request a quote.

Need this done for your business?

IT Perfection plans, installs and supports this for companies in Irvine and Orange County

The guides explain the steps. If you would rather have it done, planned and documented by an experienced engineer, these are the services that cover it. Design, implementation and troubleshooting work is planned and reviewed by Ali Hassani personally.

Network design and installation

Firewall, switches, VLANs and Wi-Fi planned, installed and documented.

View service

Firewall installation

New or replacement firewalls with clean rules and VPN with MFA.

View service

Network troubleshooting

Slow network, drops, Wi-Fi, VPN, DNS and DHCP problems traced and fixed.

View service