ELI5: In computer networking, what is a port?

https://lemmy.world/post/724844

ELI5: In computer networking, what is a port? - Lemmy.world

I often see that network settings have a field for logical port. What is this field.referring to?

Think of it as doors. Each port is a door to the ip address. Let's you choose/monitor what goes where
So, your head has a whole bunch of ports on it too. Eyes, ears, nose, mouth and each pore probably counts too. If that helps any.

One network interface has just one IP address, but it can have a bunch of different programs listening and talking.

A server might have both a webserver and a mail server running on the same machine - and they don't want each other's network traffic.

So you mark each packet with a destination port number, to let the server work out which program you're talking to.

Your web browser will mark all its packets with port 80 or port 443, and when the server gets those, it knows it's web traffic, and passes it to the webserver software.

Your email client will mark all its packets with port 25 or 993, and when the server gets those, it knows it's email traffic, and passes it to the mailserver software.

Typically each separate kind of network service will have its own well-known port number assigned to it.

There's also a source port field on packets, so that your computer can get return traffic back to the right program running on your machine.

For convulsion’s sake, one network interface can have more than one ip.
Ok I have a follow up question if you'll indulge me - why those numbers in particular?
No reason, they're conventions. Check out this list and you'll get a better idea. It's simply a number that the developer assigns without a particular meaning. It's kinda like telephone help lines, one thing that a developer might want to try is to find a pretty memorable number while trying to avoid conflicts with other programs running at the same time.

id say your telephone number example can be extended:

1800 is for free numbers, but why? no particular reason, just that’s the number that got chosen at some time… same with port 80 being HTTP: that’s just the number that got chosen!

you can also have an HTTP server running on port 25 (usually mail); it’s just bad practice… just like there’s no reason why your phone company couldn’t make a regular phone number toll free!

what’s pretty normal though is running an HTTP server on say, port 5000: this is just for more technical users though, because you have to know the port; your browser doesn’t “remember” it for you

There’s something important missing from most of the other answers. There’s a lot of different kinds of network and internet traffic. Web browsing, email, instant messaging, online video games…

By formal standard, certain port numbers are designated for certain functions. Web traffic happens on port 80. Incoming email is sent on port 143, outgoing email is sent on port 456 or 587. Something like Discord will have a specific port it uses for both sending and receiving messages. Word of Warcraft has certain ports its uses for telling the server when you cast a spell, and for the server to tell your client when you take damage.

So yes, ports are like PO boxes at a post office, but the analogy doesn’t quite capture it. Port 80 is always web traffic, and this is important, since your web browser requests pages on port 80, just as a web server returns web pages on port 80. The web server probably has other ports on it, like FTP (ports 20 and 21) or SFPT (port 22). If you connect to a web server on port 80, that means you’re asking for its webpages. If you connect on 20, 21, or 22, it means you’re trying to transfer files to it.

All true, except almost all web traffic nowadays is over port 443 (HTTPS) instead of 80.

Word of Warcraft

Is Blizzard branching out into religious literature or word processing programs? 🙂

@BackOnMyBS You may find good information by searching 'well known ports'. There are good explanations under that.
A TCP packet has a segment for a numerical descriptor which is metaphorically referred to as a port. A lot of networking hardware and software filters based on that packet segment, or directs it to particular software registered as 'listening' for that number.
Transmission Control Protocol - Wikipedia

The simplest description, and the one that stuck with me, is telephone extensions. You have one general phone number (your computer's IP), but to reach a certain program inside the computer you have to dial a certain extension (port number) as the program is only listening on that particular extension. Some of those extensions are predefined so you don't need the know them, they are programmed into the sender software (web traffic over 443 (https) or 80 (http) for example, others you need to know the extension to be able to communicate (a friend setting up a Minecraft server for example). A firewall can block certain types of traffic by not allowing traffic to certain extensions (you can't communicate with the torrent client if those extensions are blocked), port forwarding works by taking traffic for a certain extension and sending it out over another, ...

Additionally to all the correct answers, a 'port' can also mean something completely different 'in networking'.

It can be a physical socket in a network equipment, like 'Ethernet port'. Or it can be a virtual equivalent of such, e.g. when connecting virtual machines on a host - that could be called a 'logical port'.

Those can sometimes be used interchangeably with 'interface' or 'device', but it depends on convention used in particular system or environment.

If an ip address is a house number, then a port is an apartment number.
That's the only true ELI5 answer

Imagine you need to go see your doctor. They work in a building with 65535 rooms. Some rooms are empty. Some rooms have people in them that provide different services. But you need your doctor so you look their location.

You learn the building address (IP address) and the room number (port)

In practice, you attach services to specific ports so that other computers can access those services. Typically, http traffic is on port 80 and https is on port 443. So if you visit a website, you are likely connected to a server on one of those two ports. But it’s not a requirement. You could create a website and put it on port 2097, or 532, or 47210; it doesn’t matter.

And the best port of all, 25565
Haha knew that one sounded familiar but it's been a while
What's the reference?
It's for Minecraft, haha

If you would compare a server to a building, with its own street address, then port would be an apartment number for every application (tenant) living there.

Ports are what allowing you to run multiple applications and all can communicate over the internet. Without ports you would need to have separate dedicated computer for every application.

The IP address is the building, and the port is the apartment.

A port is like an apartment number. Except instead of apartments, it’s just mailboxes. Bob’s mailbox is number 25. If you want to get a message to Bob, uou write “box 25” on the address.

A port number is just an additional piece of info that the operating system associates with a particular program. If something comes in on port 22, the sshd is going to handle it because it’s “listening on port 22”, meaning that it has registered itself with the OS as the recipient of anything that comes in marked “port 22”.