How to set up port forwarding — what comes before and after the rule matters more

Typing one forwarding rule into your router takes a minute. When it fails, the reason is usually before or after that step. Pinning the address, testing from outside, and checking whether another box sits in front of your router, in order.

You have started a game server at home, or you want to reach your NAS or camera from outside, or you turned off UPnP and one console now misbehaves. Sooner or later you end up forwarding a port.

Adding one rule on the settings page is not hard. When it fails, it almost always fails just before or just after that step. This post covers both, in order.

What port forwarding does

Your router does not accept connections that start from outside. It only lets in replies to requests that went out from inside the house. A connection that arrives first from outside is dropped because the router has no idea which device in the house it is for. The router has one outside address, and several devices sit behind it.

Port forwarding writes that answer down in advance: “Anything arriving at this port on the outside address goes to this inside address, on this port.” That one line is the whole rule.

A connection from outside passes through the router’s rule table and is handed to one device in the house.

① A connection arrives from outside, aimed at your router’s outside address and a port number. ② The router looks the port number up in its rule table. ③ It hands the connection to the device at the inside address written in the rule. ④ If another box sits in front of your router, the connection never reaches the router at all.

The rest of this post is about ③ and ④.

First, does it really need to be open

An open port is not open just to you — it is open to the whole internet. Automated scanners knock on open ports around the clock, and they find new ones quickly.

So check a few things first.

  • Does the device maker’s app already give you outside access? Cameras and NAS boxes usually have their own remote access. If that works, there is no reason to open a port
  • Is it only you who needs to get in? Then a way for you to come into the house, such as your router’s VPN server feature, is the better fit. There is only one door, and it asks who you are
  • Do other people need to get in? For something like a game server your friends join, port forwarding is the right tool

Never forward your router’s admin page, remote desktop, or a camera’s web settings page. Each of those is one guessed password away from wide open.

Step 1: Find the device’s inside address

The rule needs the address of the device in your house. It looks like 192.168.0.23.

There are two places to look.

  • The connected-devices list on your router’s admin page shows names and addresses together. It is the same list from who is connected to your Wi-Fi
  • The device’s own network settings. On a PC that is the network details screen; on a console, the network settings page shows an IP address

Step 2: Pin that address

This is the step people skip most, and it accounts for nearly every case of “it worked for a few days, then stopped.”

Your router lends each device an address when it joins (DHCP). The loan has an expiry, and after a reboot of the router or the device it may hand out a different address. The rule still points at the old one. In the diagram, the arrow at ③ now points at an empty spot or at the wrong device.

So pin the address before you add the rule. The menu name depends on the maker.

  • DHCP Reservation / Address Reservation
  • Static IP assignment / Manual IP assignment

Pick the device on that screen and lock it to the address it has now. You can also fix the address on the device itself, but the router may then lend that same address to something else, so reserving it on the router side causes fewer tangles.

Step 3: Add the rule

The menu goes by names like these.

  • Port Forwarding
  • Virtual Server
  • NAT settings → Port Forwarding

There are usually five fields.

Field What to enter
Name Something you will recognise later, like “living room game server”
Protocol TCP, UDP, or both, as the program’s own instructions say
External port The number people outside will knock on
Internal IP The address you pinned in step 2
Internal port The number the program on the device listens on. Usually the same as the external port

For example, a Minecraft Java Edition server uses TCP port 25565 by default. External 25565, internal IP set to the server PC’s address, internal 25565.

Take port numbers from the program’s official documentation. Lists of port numbers on random blogs are often out of date once a new version ships.

Step 4: Test from outside

There is one common mistake here. Do not test while your phone is on your home Wi-Fi.

When you connect from inside the house to your own outside address, some routers cannot turn that connection back around. The rule is fine, but you see a failure. The reverse is also true: connecting to the inside address and getting through tells you nothing about port forwarding.

Test like this instead.

  1. Turn off Wi-Fi on your phone and connect over mobile data
  2. Or enter the port number on a port-check website

If you use a port-check site, the program on the device has to actually be running. Even with a correct rule, the port shows as closed if nothing is listening on the other end.

Still failing? Look in front of your router

This is ④ in the diagram. If the rule is right and the program is running but outside connections still fail, the connection may not be reaching your router at all.

Comparing two addresses settles it.

  1. On your router’s status page, find the internet (WAN) address
  2. From a device on your home Wi-Fi (not your phone on mobile data), open a “what is my IP” site and note the address the outside world sees

If the two match, your router is at the front of the line and ④ is not the problem. If they differ, something sits in front. How the WAN address begins tells you what.

Router’s WAN address What it means What to do
Starts with 192.168., 10., or 172.16.–172.31. There is a second router in your house, usually the ISP’s modem-router combo Add the same rule on the front box too, or switch that box to modem mode. See the post on ISP routers
Starts with 100.64.–100.127. Your ISP is putting many homes behind one outside address (CGNAT) It cannot be opened from your house. Ask the ISP for a public IP, or use a method that does not need an open port

In the second case, no setting inside your home will fix it. Run this comparison before you lose an afternoon.

Other places it gets stuck

  • The device’s own firewall. On a PC, the operating system’s firewall may be blocking the program. The router passed the connection along and the PC refused it
  • Another rule already uses the number. If an entry that UPnP created on its own uses the same external port, the two clash. Check the rule list as well
  • Your ISP blocks certain ports. Some ISPs block a few web and mail port numbers on home lines. Switching the external port to a different number tells you whether this is it

Delete it when you are done

If you have shut the game server down or got rid of the device, delete the rule as well. Rules outlive the devices they were made for, and if another device later picks up that address, the door opens onto it. Release the reservation from step 2 at the same time.

Summary

Order What to do If you skip it
0 Decide whether it really needs to be open A door you do not need is open to the whole internet
1 Find the device’s inside address Nothing to put in the rule
2 Pin the address on the router It stops working a few days later
3 Add the rule —
4 Test over mobile data A working rule looks broken
5 If it fails, compare WAN addresses An afternoon lost in front of CGNAT
6 Delete it when unused The door opens onto the wrong device

The rule itself goes in within a minute. The time goes into steps 2 and 5 — and if you know about both beforehand, the whole job takes minutes.

Common questions

My home address keeps changing. Do I need a static IP from the ISP?

Almost never, and the thing you want instead is dynamic DNS. Most home lines get a public address that changes every so often, which breaks nothing about the rule itself but does mean the address you gave your friends stops working. A dynamic DNS service gives you a fixed name that follows the address, so people connect to a name rather than a number. Many routers have this built in under a DDNS menu, often with the maker’s own free service, and that is the easiest place to set it up because the router already knows when its address changes. Note that this is a different problem from step 2: the reservation pins the inside address, and DDNS tracks the outside one.

Does any of this apply on IPv6?

The idea carries over but the mechanism does not. IPv6 has enough addresses that devices get their own public one, so there is no translation to write a rule for. What stands in the way is the router’s firewall, and what you open is usually called a pinhole or an IPv6 firewall rule rather than port forwarding. Two practical consequences: the rule names the device’s own IPv6 address rather than a 192.168. one, and the address can change when the prefix does, so look for the option to match the device by its interface identifier. If something reaches you over IPv6 but not IPv4, a CGNAT line is the usual explanation.

Is picking an unusual external port number a security measure?

It cuts the noise, not the risk. Moving a service off its default number means the broad scans that sweep common ports stop filling your logs, which is a real convenience. It does not stop anything that scans your address properly, because a full scan finds the port wherever you put it. Treat it as housekeeping and keep the thing that actually matters: the service behind the port needs a password worth having and software that is kept updated. An unusual port number in front of an unpatched service buys you nothing.