If an ip address is a house number, then a port is an apartment number.
That's the only true ELI5 answer
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.
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.
Imagine your network card is a house. That house has an address (IP address in this case) and to get into the house you need doors (ports). The house is pretty big so it has exactly 65,535 doors (ports). But because the owner of the house is not insane, most of the doors are locked (firewall).
When something communicates with you (or you with something), you use a port. For example when you open a webpage, your browser sends a request to the server on port 80 or 443 (80 for http, 443 for https). Those are standardized ports which have a well-defined meaning, but in general you only need the client (browser, app, whatever) and server to use the same port for the service.
Let me know if that clears it up!
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 the port for a Minecraft Java server.
It's for Minecraft, haha
Ports are a way of sorting requests sent to the same physical device into different services. If a single device is providing three different services, you want to send your request to the right service on the device. For example, maybe your device has a website, a piece of accounting software, and an online video game running on it. If it weren't for ports, you'd need three different devices to run those three different programs. But with ports, as long as I know what port the service I want is on, I can send my request to the right service on that device.
If you have limited money to buy devices but you want to make a lot of different apps, ports are important. Ports are also important if you're a business like Google that provides lots of different services.
Imagine a computer is like a building that can provide goods and services such as coffee shop, travel agency, bookshop, movie rental, etc. and has a street address, that would be the network address. That address would take you to the building door, but you still need to know on what floor is the service you're looking for. That would be the port number.
Expanding on the building analogy. It's more like a package gets dropped off at the building with a room number (port number) attached. The building mail room (operating system) Then hands this package off to the room number listed. With the room being some process ruining on the computer
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 a dedicated computer for every application.
Think of it as doors. Each port is a door to the ip address. Let's you choose/monitor what goes where
Your IP address is like the main office number for your computer. The ports are like internal extension numbers.
When you're setting up a program and it's asking you what logical port it should use, It's asking you which extension it should be using. Just like if you were dealing with phone numbers and phone systems you have to give it a number that's not already in use, and it probably makes sense to give it a number that is known for that type of service.
Imagine you have a bunch of island countries. Each country needs to communicate with other countries for several affairs and to trade. A network connection is a route where boats transit back and forth between two said countries with people and things. The location of each island is encoded with a unique address, called an IP (Internet Protocol) address. The thing is, each country also has a huge, massive amount of different sea ports. A big amount of them. To be precise, 65536 different ones.
Each port number is associated with a service or a city that benefits from said sea traffic and expects boats. So to send a boat from one country to another, you need to send that boat from a specific port to a specific port in country (IP address). For example, port 80 is Website City in Google Land. You need to google something / send and receive boats with cargo (your search query). You have to send a boat from your own port 80 (Firefox Town) to Google Land (IP address of a Google server)'s own port 80 which is located in Website City.
Each network connection is a series of sea trips between cities.
So, you know when you want to send a letter to someone, you need to write their address on the envelope? That address tells the post office exactly where your letter needs to go. But imagine if the person receiving the letter lives in a big house with many apartments and many people. Just the house address might not be enough. You might also need to specify the apartment where the person you want to receive the letter is located.
In computer networking, the 'address' is like the IP address of a computer. It tells the network where to send the information. But computers are like a big house converted to apartments. They can do many things and run many applications at the same time. Each of these applications is like a person in a different apartment in the house.
The 'port' is like the apartment number in the house. When information arrives for a particular IP address (the house), the port number (the apartment number) makes sure the information gets delivered to the right application (the right person in the right apartment).
So, when you play an online game, or use a web browser, or send an email, each of these applications uses a different port number. This allows your computer to know which application should receive the information that's coming from the internet.
In summary, in computer networking, a port helps your computer sort incoming and outgoing data so it goes to the right program.
what's port forwarding
Exactly what it says on the tin. It forwards mail/packets received on one or more ports to specific ports on another machine on the network.
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.
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.
Imagine the computer as a shopping mall, which has a name and address (i.e the IP address).
A port is a specific store in that mall, from were you can get specific things.
The analogy even holds further in that for certain "stores", the same store by name of certain chains (i.e. Burger King) will provide the same service in different malls if its present there (for example, port 80 is were the HTTP service is, by convention) and the same kind of service can be provided in other stores (nobody stops you from having an HTTP service on a different port).
Were the analogy breaks is that unlike with chain store names (which are protected by trademark) there really is no enforcement that a certain port has a certain service (i.e. you can put whatever service you want on port 80 of a computer you control) and certain services being in certain ports is merely a convention.
Think of your network connection as a multi-laned road and each port is it's own lane. This way many cars can drive on the same road and not commute with each other.
If IP addresses are streets, ports are mailboxes.
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, ...
it's like a gate - certain kinds of traffic (what type it is) goes though the gate, other types of traffic goes through a different gate. software is designed to look for data that passes through specific gates.
for example, unsecured http data is port 80, secured http is port 443.
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.
Explain Like I'm Five
Simplifying Complexity, One Answer at a Time!
Rules
- Be respectful and inclusive.
- No harassment, hate speech, or trolling.
- Engage in constructive discussions.
- Share relevant content.
- Follow guidelines and moderators' instructions.
- Use appropriate language and tone.
- Report violations.
- Foster a continuous learning environment.