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.
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 (:).
- Destination: 10.54.16.4:80
- Source: 10.51.34.21:63134
There are different ports depending on their number:
|Well known port numbers||0 – 1023||Well known ports are ports that occur very often in computer networking and are, as the name suggests, well known.|
|Other registered port numbers||1024 – 49151||Port 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 – 65535||Dynamically 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.
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.
A tutorial on how to open CMD can be found here.