DEV Community

Harsh Mishra
Harsh Mishra

Posted on

Guide to TCP/IP Ports and UDP Ports

🌐 Comprehensive Guide to TCP/IP Ports and UDP Ports

In networking, ports are essential for communication between devices and services over the internet or local networks. TCP/IP and UDP ports are widely used in modern networking, forming the backbone of data transfer and application-level communication.

In this article, we’ll break down the concept of ports, the differences between TCP and UDP, and their most important port assignments. Let's explore!


📚 What Are Ports in Networking?

A port is a logical endpoint used to identify specific services or applications on a device. Ports, combined with an IP address, form a socket that facilitates communication between systems.

Types of Ports:

  1. TCP (Transmission Control Protocol) Ports: Reliable, connection-oriented communication.
  2. UDP (User Datagram Protocol) Ports: Fast, connectionless communication.

🔄 Differences Between TCP and UDP Ports

Feature TCP UDP
Connection Connection-oriented (requires handshake). Connectionless (no handshake required).
Reliability Ensures reliable data delivery with acknowledgments and retransmission. No guarantee of delivery or acknowledgment.
Speed Slower due to error checking and retransmission. Faster due to minimal overhead.
Use Cases File transfer, web browsing, emails. Real-time communication, DNS queries, streaming.

🛠️ Common TCP Ports

TCP ports are used for applications requiring reliability, such as file transfers, emails, and secure connections. Below are some of the most critical TCP ports:

Protocol/Service Port Number
HTTP (HyperText Transfer Protocol) 80
HTTPS (HTTP Secure) 443
FTP (File Transfer Protocol) 20 (Data), 21 (Control)
SSH (Secure Shell) 22
SMTP (Simple Mail Transfer Protocol) 25
IMAP (Internet Message Access Protocol) 143
POP3 (Post Office Protocol 3) 110
SMB (Server Message Block) 445
RDP (Remote Desktop Protocol) 3389
MySQL Database 3306
PostgreSQL Database 5432

Common UDP Ports

UDP ports are essential for fast, connectionless communication. They are widely used in real-time applications, streaming, and DNS queries. Here are some important UDP ports:

Protocol/Service Port Number
DNS (Domain Name System) 53
DHCP (Dynamic Host Configuration Protocol) 67 (Server), 68 (Client)
TFTP (Trivial File Transfer Protocol) 69
SNMP (Simple Network Management Protocol) 161
RIP (Routing Information Protocol) 520
VoIP (Voice over IP, SIP) 5060
RTP (Real-Time Protocol) Dynamic Ports

🌍 Well-Known TCP/IP and UDP Ports

Well-known ports (0–1023) are assigned to commonly used services. These ports are managed by the Internet Assigned Numbers Authority (IANA).

TCP Well-Known Ports

Protocol/Service Port Number
HTTP 80
HTTPS 443
FTP 20, 21
SSH 22
Telnet 23
SMTP 25

UDP Well-Known Ports

Protocol/Service Port Number
DNS 53
DHCP 67, 68
SNMP 161
TFTP 69
RIP 520

🔑 Registered Ports (1024–49151)

Registered ports are used by specific applications and services. Both TCP and UDP can use these ports.

Application/Service Protocol Port Number
Microsoft SQL Server TCP 1433
Redis TCP 6379
GitLab (Self-Hosted) TCP 80, 443
Docker Registry TCP/UDP 5000
SIP (Session Initiation Protocol) UDP 5060
PostgreSQL TCP 5432

🌟 Dynamic/Private Ports (49152–65535)

These ports are dynamically assigned for temporary use by client devices when initiating communication with a server.

  • Ephemeral Ports: Randomly chosen by the operating system for short-term connections.
  • Commonly used for real-time communication protocols like WebRTC and VoIP.

🖥️ Use Cases for TCP and UDP Ports

TCP Use Cases:

  • File Transfer: Protocols like FTP and SCP rely on TCP.
  • Web Browsing: HTTP/HTTPS uses TCP for secure and reliable delivery.
  • Email Communication: SMTP, IMAP, and POP3 ensure email delivery.

UDP Use Cases:

  • Streaming Services: Real-time video and audio streaming like YouTube or Zoom.
  • Gaming: Fast-paced online games rely on UDP for reduced latency.
  • VoIP: Voice communication over the internet.
  • DNS: Resolving domain names to IP addresses.

🚀 Why Understanding TCP/IP and UDP Ports Matters

  1. Firewall Configuration: Open or close specific ports to control traffic flow.
  2. Troubleshooting: Diagnose connectivity issues by identifying blocked ports.
  3. Deployment: Configure application services correctly in production.
  4. Security: Protect against port-based attacks like DDoS by monitoring traffic.

📝 Conclusion

TCP and UDP ports are foundational to networking, powering everything from web browsing to real-time communication. Understanding the differences between TCP and UDP, along with the common port assignments, is critical for IT professionals and developers.

Top comments (0)