Skip to content
GEEKnodes

Computing

NAT and Port Forwarding on Your Router: Step-by-Step and CG-NAT

Why your device has a private IP, how NAT works, how to forward a port on your router step by step and how to tell whether your ISP uses CG-NAT.

You set up a game server, a camera or a NAS at home and there’s no way to connect from outside. The culprit is almost always the router’s NAT, which blocks incoming connections from the internet by default. In this guide you’ll see why that happens, how to forward a port step by step, how to tell whether your ISP has you behind CG-NAT and what safer alternatives exist.

In short

  • Your devices have private IPs; the router translates them to a single public IP using NAT.
  • Forwarding a port means telling the router which internal device should receive whatever arrives on that port.
  • If your ISP uses CG-NAT, forwarding ports on your router won’t help: you need a public IP or a VPN.

Why your device has a private IP

There are about 4.3 billion IPv4 addresses, far fewer than there are connected devices. The solution was to reserve private ranges that repeat in millions of homes and aren’t routed on the internet:

Private rangeCIDR notationWhere you’ll see it
10.0.0.0 – 10.255.255.25510.0.0.0/8Businesses, some routers
172.16.0.0 – 172.31.255.255172.16.0.0/12Corporate networks, Docker
192.168.0.0 – 192.168.255.255192.168.0.0/16Almost every home router
100.64.0.0 – 100.127.255.255100.64.0.0/10ISP CG-NAT

Your laptop can be 192.168.1.34 and so can your neighbor’s. To the outside world, each goes out with its own router’s public IP.

To see your private IP:

ipconfig
# macOS
ipconfig getifaddr en0
# Linux
ip -4 addr show

How NAT works

NAT (Network Address Translation) is the translation the router performs between private and public IPs. What’s used at home is actually NAT with ports:

  1. Your laptop 192.168.1.34 opens a connection from its port 51000 to a website.
  2. The router replaces the source with its public IP and a free port, for example 40112, and records it in its NAT table.
  3. The website replies to the public IP, port 40112.
  4. The router checks the table, sees that it belongs to 192.168.1.34:51000 and delivers the reply.
NAT diagram: a laptop with a private IP goes out through the router, which translates to its public IP and records the connection in the NAT table
The router translates private IP to public and records each connection to route the reply back

The key is step 4: it only works if the connection started inside. When someone outside tries to connect with no prior entry in the table, the router doesn’t know which device to send it to and drops it. That protects you, but it prevents you from hosting services.

TCP and UDP: pick the right protocol

Each forwarding rule applies to a protocol. Getting this wrong is one of the most common mistakes.

TCPUDP
ConnectionSets up a session before sendingSends without a session
ReliabilityResends what’s lost, keeps orderNo guarantees
Typical usesWeb (80, 443), SSH (22), RDP (3389)Games, voice, WireGuard VPN (51820), DNS (53)
Ease of testingEasyHard: there’s no standard reply

If the program’s documentation says “TCP/UDP”, create the rule for both (most routers have a “Both” option).

Step 1: give the device a fixed IP

A forwarding rule points to a specific internal IP. If the router gives the device a different IP after a restart, the rule stops working. There are two ways to avoid that:

  • DHCP reservation (recommended): in the router you tie the device’s MAC address to an IP. The device stays on automatic and always gets the same one.
  • Static IP on the device itself: choose an IP outside the range the router’s DHCP hands out to avoid conflicts.

DHCP reservation is usually under LAN › DHCP › Static leases or something similar.

Step 2: forward the port

Menus vary by manufacturer, but the information they ask for is always the same:

  1. Log in to the router from your browser, usually at 192.168.1.1 or 192.168.0.1 (the default gateway shown by ipconfig).
  2. Look for Port Forwarding, NAT or Virtual Servers.
  3. Create a new rule with:
    • External port: the one that will be used from the internet.
    • Internal IP: the fixed IP from step 1.
    • Internal port: usually the same as the external one.
    • Protocol: TCP, UDP or both.
  4. Save and, if it asks, restart the router.
  5. Check that the device’s firewall allows that port. On Windows, Windows Defender Firewall blocks new inbound connections by default.
Port forwarding: a connection from the internet to the router's port 25565 is sent to the internal device 192.168.1.50
A forwarding rule tells the router which internal device gets what arrives on a port

An example rule for a server listening on port 25565:

Name:           game-server
External port:  25565
Internal IP:    192.168.1.50
Internal port:  25565
Protocol:       TCP

You can use an external port different from the internal one (for example, external 2222 to internal 22) to cut down the noise from bots probing well-known ports. It’s not a real security measure, but it lightens the logs.

CG-NAT: when port forwarding doesn’t help

Some ISPs, especially on budget fiber, mobile and 4G/5G home internet, don’t give each router a public IP. They use CG-NAT (Carrier-Grade NAT): your router gets a private IP from the ISP and it’s the ISP that does a second NAT toward the internet. You don’t control that NAT, so no rule on your router will ever receive traffic from outside.

How to detect it

  1. Log in to the router and find the WAN IP or internet IP on the status page.
  2. Check your public IP from a device on the network:
curl https://ifconfig.me
  1. Compare:
    • They match: you have a public IP. You can forward ports.
    • The WAN starts with 100.64 to 100.127: almost certainly CG-NAT.
    • The WAN is 10.x, 172.16-31.x or 192.168.x: either CG-NAT or double NAT because there’s another router in front (for example, the ISP’s with your own router behind it).

For home double NAT, the fix is to put the ISP’s router in bridge mode or forward the port on both. With CG-NAT, the option is to ask your ISP to take you off CG-NAT or assign you a public IP; some do it for free and others as a paid add-on. It’s worth asking.

Another route is IPv6: if your ISP offers it, every device has its own public address and there’s no NAT. You only need to allow the port in the router’s IPv6 firewall, although the connecting client also needs IPv6.

UPnP: convenient but risky

UPnP lets a program ask the router to open a port automatically. Consoles and some games use it to avoid the dreaded “strict NAT”.

The problem is that any program on the network can ask, with no password or confirmation. Malware on a computer or a cheap camera with vulnerable firmware can expose itself to the internet without you knowing. On top of that, there have been routers that accepted UPnP requests from the internet side due to implementation bugs.

Practical advice:

  • Turn UPnP off if you don’t need it.
  • If you need it for a console, check the router’s UPnP table now and then to see which ports are open and who requested them.

How to check whether a port is open

First confirm that the service is listening on the device itself:

netstat -ano | findstr :25565
ss -tlnp | grep 25565

Then test it from outside your network. From inside it often fails even when it’s set up correctly, because not every router supports NAT loopback (connecting to your own public IP from inside). Use your phone’s cellular data or a computer on another connection:

nc -zv YOUR_PUBLIC_IP 25565

In PowerShell:

Test-NetConnection YOUR_PUBLIC_IP -Port 25565

For UDP there’s no reliable generic test: the most practical thing is to use the service’s own client.

Safer alternatives: VPN

Every open port is a door that bots around the world try every day. If the service is just for you or a few people, it’s better not to expose it:

  • Your own VPN: you set up a VPN server at home (WireGuard or OpenVPN) and open a single port, the VPN’s. When you connect, you’re “inside” your network and can reach everything without any other open ports.
  • Mesh VPNs or outbound tunnels: the device at home opens an outgoing connection to an intermediary service. It doesn’t require opening ports and works even with CG-NAT.

What you should never expose directly: remote desktop (RDP on 3389), router or NAS admin panels, and databases.

Common mistakes

  • Rule pointing to an IP that has changed: the DHCP reservation is missing.
  • Wrong protocol: a TCP rule for a service that uses UDP.
  • Device firewall blocking: the router forwards fine, but Windows or Linux rejects the connection.
  • Testing from inside the house: without NAT loopback the test fails even if everything is fine.
  • Service listening only on 127.0.0.1: the program only accepts local connections. It must listen on 0.0.0.0 or on the network IP.
  • Not noticing CG-NAT or double NAT: always compare the WAN IP and public IP before you keep hunting for the fault.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor