423 words
2 minutes
Port Forwarding
2024-12-24

What Is Port Forwarding#

Port forwarding is a technique that takes traffic arriving at a specific network port on one device or network and relays it to another. It’s usually configured on a router or firewall to direct incoming requests from the internet to a specific device or service inside your internal network.

How It Works#

Port forwarding works in three steps:

  1. External request: A user on the internet sends a request to your router’s public IP address on a specific port (e.g. http://<public-ip>:8080).
  2. Router handling: The router receives the request and, following its port forwarding rules, forwards it to the designated internal IP and port (e.g. 192.168.2.2:5244).
  3. Service response: The internal device processes the request and sends the response back through the router to the external user.

Prerequisites#

  • A service running on your internal network
  • A public IP address
  • Either the admin (super admin) password for your optical modem with port forwarding support, or the modem switched to bridge mode so your router handles the PPPoE dial-up and port forwarding

Modem Configuration#

In my setup the optical modem handles the PPPoE connection, so the port forwarding rules live in the modem’s admin panel. The sticker on the back of the modem usually lists the admin URL and credentials — but that’s a regular user account without permission to change these settings. You need the super admin account.

I got mine by paying someone on Xianyu (a Chinese second-hand marketplace) to retrieve the modem’s super admin password, then locked it in so it wouldn’t rotate.

Using my modem, a ZTE G7615, as an example:

  1. Log in to the modem admin panel at http://192.168.2.1/cu.html
  2. Go to Advanced Configuration → NAT Settings → Virtual Host Configuration
  3. Fill in Name, Protocol, WAN Start Port, WAN End Port, Virtual Host IP Address, and Virtual Host Port
    • Name: anything you like, e.g. AppleTV-alist
    • Protocol: TCP or UDP, depending on the service you’re exposing
    • WAN Start Port: 5244 — the port exposed to the public internet
    • WAN End Port: 5244 — same as above
    • Virtual Host IP Address: 192.168.2.2 — the internal IP where the service runs
    • Virtual Host Port: 5244 — the internal port of the service
  4. Click Add

Adding a rule

Once the rule is in place and you have a public IP, the internal service is reachable at http://<public-ip>:5244.

In my case, that service is an AList instance:

AList

Final Notes#

Port forwarding lets you reach internal services via a public IP, but it has real drawbacks:

  • Most home broadband connections don’t come with a public IP; you have to request one, and there’s no guarantee you’ll get it
  • Public IPs are usually dynamic, so the address changes over time (this can be solved with ddns-go)
Port Forwarding
https://www.mihouo.com/en/posts/network/port-forwarding/
Author
Jia
Published at
2024-12-24
License
CC BY-NC-SA 4.0