TutorChase logo
Login
AQA A-Level Computer Science

18.4.4 Well-known and client ports

Network communication relies on ports to direct data to the correct application or service on a device. Understanding how these ports work and are allocated is essential for anyone studying computer networks.

What are ports?

A port is a 16-bit numerical identifier used in networking to distinguish between multiple processes or services running on a device. Ports allow computers to run various services simultaneously and enable proper routing of data between devices. While an IP address identifies a device on a network, the port number identifies the specific service or application on that device.

Each port number falls within a range of 0 to 65535, making 65,536 total ports available. These are split into three main categories:

  • Well-known ports (0–1023)

  • Registered ports (1024–49151)

  • Dynamic or private ports (49152–65535)

Without ports, a device would struggle to handle multiple services like web browsing, email, and file transfers at the same time, since it wouldn't know which incoming data belongs to which application.

Categories of ports

Well-known ports (0–1023)

Well-known ports are the first 1,024 ports and are tightly regulated by the Internet Assigned Numbers Authority (IANA). These ports are permanently assigned to the most widely used Internet services and protocols.

Characteristics:

  • Reserved for standardised services used across the Internet.

  • Only administrative processes (such as root users on UNIX-based systems) can bind to these ports.

Take your grades to the next level!

UPGRADING TO PREMIUM UNLOCKS
AI Tutor
AI-powered study assistant
instant feedback and guidance
Predicted Papers
Examiner-style predicted papers
based on recent exam trends
Practice Questions
All exam practice questions
by topic for each subject
Study Notes
All detailed revision notes
written by expert teachers
Cheat Sheets
Quick revision summaries
perfect for last-minute review
Past Papers
Complete collection
of practice and past exam papers
Email
Password
Confirm Password
Already have an account?

Practice Questions

FAQ

Services are occasionally configured to run on non-standard ports to enhance security, avoid conflicts, or for testing purposes. Running a service like SSH on a port other than the default port 22 makes it slightly harder for automated bots or attackers to identify and exploit it, a technique known as "security through obscurity." It can also help in avoiding port conflicts when multiple services that use the same port need to coexist on a single machine. For example, if two web servers are installed on one system, one might run on port 80 and the other on port 8080. In testing environments, developers often run applications on alternative ports to prevent disruption to live services. Firewalls and routers may also block default ports in restrictive networks, so administrators use custom ports to ensure connectivity. However, changing the port does not replace proper security configurations and should only be part of a broader security strategy.

When two services attempt to bind to the same port on the same IP address, a port conflict occurs, and the operating system will reject the second binding attempt. The service that attempts to bind first typically secures the port, while the second service fails to start or throws an error. This is because only one application can actively listen on a specific port at a time for a given IP address. Operating systems handle this by checking the port binding request against existing active bindings in the system's network stack. If a port is already in use, the system prevents another process from using it to maintain proper communication flow and avoid data routing confusion. Developers and system administrators must carefully manage port allocations, especially on shared or multifunctional servers. They can resolve conflicts by choosing unused ports, configuring services to bind to different network interfaces, or using tools to monitor active port usage such as netstat or ss.

Yes, port numbers can be reused across different IP addresses and across different transport layer protocols such as TCP and UDP. This is possible because a socket, which uniquely identifies a communication endpoint, is defined by a combination of IP address, port number, and transport protocol. For example, TCP port 80 and UDP port 80 are treated as completely separate entities. Similarly, TCP port 80 can be bound to different network interfaces or IP addresses on the same machine, allowing multiple services to use the same port as long as they are associated with different IPs. This is especially common in servers with multiple network interfaces or in virtualised environments where multiple services run in containers or virtual machines with separate IP addresses. However, two services cannot bind to the same port on the same IP address using the same protocol. Understanding this flexibility allows system administrators to design more efficient and scalable networked systems.

Network Address Translation (NAT) allows multiple devices on a private network to access the Internet using a single public IP address by modifying packet headers. Since each device may be running multiple applications, NAT uses port numbers to track and manage connections. When a device initiates a connection, NAT maps the private IP address and port number (e.g. 192.168.0.5:53000) to the public IP and a unique external port number (e.g. 203.0.113.1:61000). This is known as Port Address Translation (PAT). The NAT device keeps a translation table so that when responses return to 203.0.113.1:61000, it knows to forward the packet to 192.168.0.5:53000. This allows thousands of simultaneous connections from different internal devices using the same public IP address without confusion. Port numbers are crucial in this process as they ensure traffic is directed to the correct internal client and application. Without port-based translation, NAT would be unable to distinguish between different users’ requests.

Network administrators use a range of tools and techniques to identify open ports and determine which services are using them. On local machines, commands like netstat -an or ss -tuln can list all active connections and listening ports along with their associated protocols. Tools such as lsof -i or netstat -plnt also reveal which processes are bound to specific ports. For remote systems, administrators often use port scanners such as Nmap. Nmap sends packets to a range of ports and analyses responses to determine which ports are open, closed, or filtered by a firewall. Additionally, intrusion detection systems and firewall logs can provide insights into port usage over time. Identifying open ports is vital for network security auditing, as unused open ports can be exploited by attackers. Best practice includes regularly scanning systems, closing unnecessary ports, and configuring firewalls to allow only essential traffic through approved ports.

Hire a tutor

Please fill out the form and we'll find a tutor for you.

1/2
Your details
Alternatively contact us via
WhatsApp, Phone Call, or Email