Port Numbers: What are port numbers and what are they used for?

In this must-read article, you will find out what ports are and why they are necessary for communication between computers.
What are ports?

A port is a communication endpoint that is used to assign different applications different “addresses” in form of numbers. This way, computers can decide what received data is useful for which application. For example, SSH is usually associated with port 22. This way, the computer knows that the received data should go to the application that handles SSH.

what are port numbers

Ports are a very important component of computer networking, and it is always good or even necessary to know what they are. Therefore, you should read this article now and find out what ports are, why computers need them, and how they work.

How do ports work

Each application that is running on a computer uses a port to communicate with other devices over the internet or within a network. If we now want to send some data to another computer, we have to specify a port that leads to the application that can handle our request on the other computer.

The receiving computer has got some defined ports for each application (Destination Ports). The sending computer, however, uses a randomly generated port (Source Ports) to connect to the defined port for the desired application on the receiving computer. After the computer has received the data, it swaps the port (The previous destination port now becomes the source port, and the previous source port becomes the destination port) and sends a response. 

When using IPv4, we specify the port after the IP address, separated by a single colon (:).

Examples:
  • Destination: 10.54.16.4:80
  • Source: 10.51.34.21:63134
Port numbers
There are different ports depending on their number:
NameRangeShort Explanation
Well known port numbers 0 – 1023Well known ports are ports that occur very often in computer networking and are, as the name suggests, well known.
Other registered port numbers 1024 – 49151Port numbers in that range are some other registered ports for applications that aren’t used very often in computer networking
Dynamically assigned port numbers 49152 – 65535Dynamically assigned ports are ports that are randomly generated and used as source ports.
Some of the most important port numbers are:
  • FTP Data → 20
  • FTP Control → 21
  • SSH → 22
  • Telnet → 23
  • SMTP → 25
  • DNS → 53
  • DHCP → 67/68
  • TFTP → 69
  • HTTP → 80
  • HTTPS → 443
  • POP3 → 110
  • SNMP → 161

A list of a lot of other ports can be found here.

How to see active ports on Linux

To see some ports in action, you can simply run the command netstat -tun in your Linux terminal to show some currently active ports.

Show ports on linux

How to see active ports on Windows

To display the active ports on your Windows computer, simply run the command netstat -n in PowerShell or CMD.

Show ports on windows

A tutorial on how to open CMD can be found here.

Summary

In conclusion, we could say that IP addresses are what gets the data to the computer, but ports are what get it to the correct application on that computer.

Thanks for reading!

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *