Free tech learning for everyone, from basics to pro

Network FundamentalsNetworking SecurityBeginner

Port forwarding, dynamic DNS and UPnP: making a service reachable, and safer alternatives

In short: Port forwarding tells a NAT router to send traffic arriving on a public port to a device inside the network. Dynamic DNS updates a name whenever the home IP address changes, and UPnP lets devices create forwards automatically. Exposing services this way is risky, especially remote desktop and camera systems, so a VPN or an outbound tunnel service is usually safer.

Why it is needed

NAT lets many devices share one public IP address, but it also means nothing on the internet can start a connection to a device inside. If you want to reach a home server, a CCTV recorder or a game server from outside, the router needs a rule saying "traffic arriving on this port goes to that device". That rule is a port forward (also called destination NAT or a virtual server).

Reaching a home service from outsideRemote usermyhome.example.netDynamic DNSname to currentpublic IPRouterport forward 443 to192.168.1.50Internal serveranswers
Figure 1. DDNS keeps the name pointing at a changing address; port forwarding sends the traffic to the right device.

Setting up a port forward

  1. Give the internal device a fixed address, ideally with a DHCP reservation.
  2. In the router, create a rule: external port (for example TCP 443) to internal IP 192.168.1.50, port 443.
  3. Make sure the device's own firewall allows the traffic.
  4. Test from outside, for example from a phone on mobile data, not from inside the home network (many routers do not support "hairpin" access to the public address from inside).

Port forwarding does not work if the router is behind CGNAT or double NAT, because the router does not own the public address.

Dynamic DNS

Most home connections get a public IP that can change. Dynamic DNS (DDNS) services (No-IP, DuckDNS, and many router vendors' own) give you a name such as myhome.example.net. The router, or a small program on a PC, updates the name whenever the address changes, so you can always connect by name.

UPnP

Universal Plug and Play lets devices and apps on the network ask the router to open ports automatically. Game consoles use it to get an "open NAT" type. The problem is that any device can ask, including malware or a poorly made camera, and the user never sees it. If you use UPnP, check its list of mappings occasionally; if you do not need it, turn it off.

The risks

A forwarded port puts that device directly on the internet, where automated scanners find it within minutes. Remote desktop (RDP, port 3389), old NAS devices, CCTV recorders and home automation hubs are constantly attacked. Many ransomware incidents in small businesses started with an exposed RDP port. If you must forward a port:

  • keep the device fully updated and use strong, unique passwords with MFA;
  • never forward RDP, SMB or admin interfaces;
  • limit the rule to known source addresses if the router allows it.

Safer alternatives

  • A VPN into the home or office (WireGuard or OpenVPN on the router or a small server): only one port is exposed, and it does nothing without the right keys.
  • Overlay VPNs such as Tailscale or ZeroTier: devices connect outward and find each other, with no ports forwarded at all, and they work behind CGNAT.
  • Outbound tunnel services such as Cloudflare Tunnel publish a web service through the provider's network, with optional login in front.
  • Vendor cloud apps for cameras and smart devices, if you trust the vendor.

Real-world example: the dentist's remote desktop

A small dental practice forwarded port 3389 so the owner could use remote desktop from home. Months later, an attacker guessed a weak password and installed ransomware over a weekend. The recovery plan removed the port forward, set up a WireGuard VPN with keys on the owner's laptop, and added MFA for remote logins.

Practice

What does a port forward do?
It tells the NAT router to send traffic arriving on a public port to a specific internal device and port.
What problem does dynamic DNS solve?
It keeps a name pointing at a home connection whose public IP address changes.
Why is forwarding RDP (port 3389) a bad idea?
Exposed RDP is scanned and attacked constantly and is a common way ransomware gets in; use a VPN instead.

Key takeaways

  • Port forwarding lets outside users reach a device behind NAT.
  • Dynamic DNS keeps a name updated when the public IP changes.
  • UPnP opens ports automatically; disable it if not needed.
  • Prefer VPNs or outbound tunnels to exposing services directly.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: