Networking Ports — Beginners start here.

Sean McNamara
7 January, 2008
View more articles fromthe author
AAA
Help

I find one of the hardest concepts in networking for new computer users to wrap their head around is the concept of networking ports — and I’m not talking about the hardware ports on the side or back of your computer. As is often the case in computers, the same name is applied to two totally different concepts, helping the confusion factor along for new users and the uninitiated. This month, we’re looking at software ports, which are fundamental to the operation of the internet.

Every computer on the internet has an IP address, a computer-friendly number-based address like 5.1.126.20. Each of the four numbers can be between 0 and 255, and there are ranges of addresses reserved for use on private networks (generally those on the user’s side of a router or modem). When you type in www.apple.com into a browser, this human- readable address is converted into the server’s IP address using the Domain Name System (DNS) servers.

At the most basic level, you can think of ports as a sub-address, which can have a value of between 0 and 65535. When coupled with an IP address, the port is separated from the rest of the address with a colon (eg 5.1.126.20:80 means port 80 at IP address 5.1.126.20).

When a packet of information arrives at a computer (or router) on the internet, it looks at the port and compares it to the list of ports it knows what to do with. The use of ports means a computer doesn’t have to look at the information inside a data packet to determine what to do with it, it just hands it over to the program that knows what to do with it.

For computers, that means it looks at any server programs it has running (web server software, file sharing services, etc.) and the ports they handle — if the port is handled by a running program, the data is handed to that program and it processes it. Certain services have default ports they operate over (such as port 80 for web servers), although they can be configured to respond to any port. If the server is using the default port, the port doesn’t have to be typed in (as is the case with almost all web servers people generally access).

For example, when a packet arrives at a computer with IP address 5.1.126.20 and port 80, the computer looks for any programs handling that port, and, if a default web server is running on the machine it has flagged that it handles port 80 and is therefore given the packet to process.

Routers are slightly different — they will either handle the data themselves (if, for example, they have a built-in web-based configuration server) or they will have been configured to pass certain ports on to particular computers on the private side of the network. This is how web servers behind routers, which are usually invisible to the internet, are able to respond over whichever port/s they’ve been configured to handle.

irewalls introduce another aspect to the handling of ports. Firewalls can be configured to filter IP addresses and/or ports (or combinations of them) selectively, to help protect the network (see [Firewall port.png]). For example, a firewall may block all access to file sharing ports except from certain computers it’s been told about.

A list of pre-defined port numbers and their associated services can be found at the Internet Assigned Numbers Authority web site (see “Hotlinks”). Wikipedia also has some information on the concepts underlying the use of ports (see “Hotlinks”).

Ports are also how routers can share a single IP address between all the computers on their network. Routers assign each outgoing connection its own external IP address and a random port in the high range, and when the data comes back in reply to that outgoing connection, the router looks up its internal list of assigned random ports and the computers they relate to then passes the data back to the requesting computer. This is called “Network Address Translation (see “Hotlinks”).

Coverage of UDP and TCP is beyond the scope of this article, but suffice it to say that they are protocols which allow for different types of conversations between computers and devices on the internet. The article on Wikipedia can tell you more if you’re interested.

Leave a Comment

Please keep your comments friendly on the topic.

Contact us