Here’s What You Need to Know About Port Forwarding - Codecademy Blog (2024)

Port forwarding is a crucial concept that often comes into play when engaging in certain activities. Whether you’re setting up a game server to facilitate seamless gaming experiences, hosting your own website directly from your home, or ensuring remote access to security cameras while you’re away, port forwarding plays a pivotal role.

​​​The examples above all involve setting up servers to be accessed from an outside source. Port forwarding establishes a connection between a router’s public IP address and the IP addresses and ports of services on a network. ​But what exactly are you doing when you ​configure​ your router? Why is port forwarding necessary? What else can it be used for?​

We’ll cover all that below, but first, let’s look at how a router works and what these ports are.

Learn something new for free

  • Intro to ChatGPT
  • Learn SQL

How a router works

A router connects the devices in a network by forwarding data packets between them. This allows devices to communicate with each other and the internet. The router tracks all the devices on the network by assigning a local IP address to each one. In the early days of the internet, a modem sufficed for single-device connections, but with the prevalence of multiple connected devices, routers became essential.

When you browse the internet, router forwards your request to the modem. When the response comes back, the router routes it back to the right device using its assigned IP address. This forwarding is necessary because only by the router knows the local IP addresses assigned to each device in the network. Any data traveling to your device never ​gets​ there directly. It must be forwarded.

What are ports?

Local IP addresses are assigned to each device connected to a router. These IP addresses are only known by the router, unlike public IP addresses that are used by DNS servers to connect you to the right server or the one that your router uses to connect to the internet.

But there is another number that works with the IP address that allows you to connect to the website: the port number. When you browse an insecure site, one that begins with http, you are connecting to port 80 on the server. When you visit a secure site, one that starts with https, you are connecting to port 443.

Just like an IP address maps all the devices on a network so they can receive data meant for them, ports map all the services and applications on a computer so that data reaches the intended service. For data to be transferred across a network, both an IP address and a port are necessary.

Here are the default port numbers of some common applications:

  • 22. ​for ​Secure Shell (SSH)​.​
  • 80. ​for ​HyperText Transfer Protocol (HTTP)​.​
  • 110. ​for ​Post Office Protocol (POP3)​.​
  • 443. ​for ​HTTP with Secure Sockets Layer (SSL)​.​
  • 3306. ​for ​MySQL database​.​
  • 5432. ​for ​PostgreSQL​.​

When you connect to any one of these services, you have to know the port number. There could be dozens of services running on the same machine or at the same IP address, and without the port, the device doesn’t know where you want the data you are sending it to go.

What is port forwarding?

Port forwarding is a map between a router’s public IP address and the IP addresses and ports of the services running on a network. It tells your router to relay data that it receives on a specific port to a specific port on a specific private IP address on the network.

​​W​hen you set up a server to host your website at home, you have to add port forwarding rules to your router. You do this by finding the IP address of the computer running your website and setting a rule to forward all traffic on port 80 to that IP address. You can also specify the port you forward the data to. For example, if you run the website on port 8080, you can forward it to that port.

Some applications only require one port to be forwarded, like the website example. Other applications use a whole range of ports for the many services they run, and you have to forward this range in the router to the device.

Many consumer applications have a feature called UPnP, or Universal Plug and Play, which will automatically set up these rules in your router. For other applications, you will have to log in to the admin screen of your router and enter the port forwarding rules manually.

Why is port forwarding important?

Your router is designed to let you connect to any service on the internet. It routes your data to the internet with the IP address and the port and allows the router on the other end of the connection to handle the details of connecting to the right server and service. When you get a response, the router knows you made the request and routes it back to you.

But what if you wanted to host a website on your home computer? People from outside your network would have to connect to your device on port 80 using an IP address only known to the router. You can set up a DNS server to point to your public IP address, but that only gets as far as your router. And your routerl has no clue what is going on. In fact, many are designed to block connections on certain ports with a firewall by default for security.

Port forwarding with TCP compared to UDP

​​There are also two types of ports that you can forward: ​​​

  • ​​​Transfer Control Protocol, or ​TCP​.​​
  • ​​​​User Datagram Protocol, or ​​UDP. ​ ​​

​​​Both of these​ protocols run on top of the I​nternet​ ​P​rotocol. The choice between TCP and UDP for port forwarding depends on the specific requirements of the service or application being used. When you are forwarding a port number, it’s also important to specify the type of port you are forwarding. ​

TCP is the most common protocol on the internet. It’s the one we use to browse websites, and it guarantees the delivery of data. Every packet of data sent to a recipient is acknowledged by the recipient so the data can be put back together reliably.

UDP doesn’t care about ​acknowledgements​. It just sends the data out and doesn’t worry about any missing data. This allows the data to stream to the device faster because it doesn’t have to go through all the back-and-forth communication that TCP does. And streaming is one of the main things UDP is used for, both for videos and video games.

What else is port forwarding used for?

​​​P​ort forwarding is necessary whenever a device outside a network must connect to a service or application running on a device in the network. Its application extends to various scenarios, like facilitating remote desktop access to your home desktop from a different location, directing traffic to your server within the network when running a public website, and hosting a VPN to enable remote internet browsing using your home network’s IP address. In these instances, port forwarding is the mechanism that ensures seamless and secure communication between devices across diverse network environments.​

Learn more about port forwarding

All services you connect to on the internet not only have an IP address but also a port number. Both are necessary to make sure data gets to where it is going. Port forwarding allows communication to get to the right device and application on a private network by mapping a router’s public IP to ports on devices running in the network.

If you want to host your own web application at your house, you’ll need to know how to forward a port. And if you want to learn how to build that application, check out our Full-Stack Engineer career path. It will teach you both back-end and front-end development skills you’ll need.

Related courses

7 courses

Intro to IT Beginner Take your first steps into the world of IT, or Information Technology! Introduction to IT will teach you about core IT subjects.
Intro to ChatGPT Beginner Learn about ChatGPT, one of the most advanced AI systems available today, and dive into the world of Generative AI.
Intro to Cybersecurity Beginner Learn about the fast-growing field of cybersecurity and how to protect your data and information from digital attacks.
Learn SQL Beginner In this SQL course, you’ll learn how to manage large datasets and analyze real data using the standard data management language.
Learn to Code with Blockly Beginner Want to learn how to get started with programming in an interactive way? Try our drag and drop code lessons!
Choosing a Programming Language Beginner This course will introduce learners to factors to consider when picking a first language as well as describe some popular options.
Choosing a Career in Tech Beginner Are you feeling confused about where to aim for with your career goals? Take this course to learn about different career options!

Subscribe for news, tips, and more

Here’s What You Need to Know About Port Forwarding - Codecademy Blog (2024)

FAQs

What do you know about port forwarding? ›

Port forwarding, also known as port management, allows remote servers and devices on the internet to be able to access devices that are on a private network. If you are not using port forwarding, only devices on that private internal network can have access to each other or your network.

How does port mapping work? ›

Port mapping is to map a port of the IP address of an extranet host to a machine on the Intranet to provide corresponding services. When a user accesses this port of the IP, the server automatically maps the request to a machine within the corresponding LAN. Port mapping can be dynamic or static.

Why do I have to port forward? ›

Port forwarding is useful whenever you need to make a direct connection between a device in your home network and a remote device. For example: Watch a security camera or baby monitor when you're away from home. Connect to your home server remotely.

Is port forwarding safer than UPnP? ›

Using it is more convenient, while port forwarding is a lot safer from a privacy standpoint. Some people go for security, and some don't.

What IP do you use for port forwarding? ›

Before initiating port forwarding, you'll need to set a static IP address for the device on the receiving end. Port forwarding only works if the final destination – your gaming computer, for example – always uses the same IP to identify itself. To set up a static IP address, head to your router's configuration page.

Does port forwarding affect other devices? ›

Port Forwarding allows computers over the internet to connect to a computer or server within a private home network. This makes your computer accessible to another computer through your network, which is being used to filter traffic to multiple devices on your network.

What is the difference between port forwarding and mapping? ›

Also called "port mapping," port forwarding is directing traffic from the outside world to the appropriate server inside a local TCP/IP network. Internet services are identified by a standard port number; for example, Web traffic uses port number 80.

Does port forwarding bypass the firewall? ›

Port forwarding allows you to bypass restrictions like firewalls, access data, and use other machines remotely without being physically present. It sounds like a difficult concept, but if you use a service like TeamViewer, Chrome Remote Desktop, or AnyDesk, you're using this technology.

How to configure port forwarding? ›

To forward ports on your router, log into your router and go to the port forwarding section. Next, enter the port numbers and your device's IP address. Choose a forwarding protocol and save your changes. Note: If you don't see a port forwarding option in your router's settings, you might have to upgrade.

What happens if you don't port forward? ›

Without port forwarding, only devices that are part of the internal network can access each other, and with port forwarding, anyone can. Whether you're making a Minecraft game accessible to your friends or hosting a small website, port forwarding is a useful way to access software running on your computer remotely.

Can you port forward without a static IP? ›

What generally happens is that the IP address your computer gives you will change, so one day you have an IP of 192.168. 1.100, and the next it might be 192.68. 1.101. Any port forwarding configuration you make on your router needs to be fixed to a certain IP address, so it's important that it doesn't change.

What are the benefits of port forwarding? ›

Port forwarding is an excellent way to preserve public IP addresses. It can protect servers and clients from unwanted access, “hide” the services and servers available on a network and limit access to and from a network. Port forwarding is transparent to the end-user and adds an extra layer of security to networks.

What are the negative effects of port forwarding? ›

If you port forward incorrectly, it can lead to security risks within your network. More specifically, it can open a network to security vulnerabilities and cyber attacks.

What is the biggest limitation of port forwarding? ›

Port Forward Limitations

A single port can only be forwarded to one internal host for each available public IP address. For instance, if only one public IP address is available, one internal web server that uses TCP port 80 to serve web traffic can be configured.

What is the most common port forwarding? ›

Local port forwarding is the most common type of port forwarding. It is used to let a user connect from the local computer to another server, i.e. forward data securely from another client application running on the same computer as a Secure Shell (SSH) client.

What is the role of port forwarding? ›

It is used to let a user connect from the local computer to another server, i.e. forward data securely from another client application running on the same computer as a Secure Shell (SSH) client. By using local port forwarding, firewalls that block certain web pages, can be bypassed.

How do I learn port forwarding? ›

You do this by finding the IP address of the computer running your website and setting a rule to forward all traffic on port 80 to that IP address. You can also specify the port you forward the data to. For example, if you run the website on port 8080, you can forward it to that port.

Does port forwarding make a difference? ›

Port forwarding is necessary if you want to host any multiplayer game. Without it, other players won't be able to join in over the internet. Make sure to check whether the game you're about to play requires port forwarding.

What is port forwarding in networking example? ›

Suppose you are at the office and want to connect to your computer which is present in your house, the computer present at the house is connected to the WiFi of house which is a LAN(Local Area Network) one of the ways to connect to your house computer is port forward ssh(port 22) in your Router to your computers IP ...

Top Articles
HazMat Labels, Markings, and Placards on an Intermediate Bulk Container - Daniels Training Services
Fixed assets: Complete guide
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 5476

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.