# Port forwarding on your router

Source: https://openpanel.sh/docs/servers/port-forwarding

Which ports a home or office server needs forwarded and why, what routers call address reservation and port forwarding, and why not to use the DMZ.

A server added with [One command](/docs/servers#one-command) needs no port forwarded: its agent only connects out. This page is for the [SSH setup](/docs/servers#connect-over-ssh).

A router hides the machines behind it from the internet. For OpenPanel to reach a server at home or in an office over SSH, the router must send some incoming connections on to that server. That takes two settings: a fixed address for the server on your network, and the port forwards themselves.

## The ports [#the-ports]

| Protocol and port | Forward to | Needed | Why |
|---|---|---|---|
| TCP 22 | the server's port 22 | For the setup | OpenPanel's first sign-in, with your password. After the setup, the server's firewall closes port 22 and you can remove this forward. |
| TCP 20000–60000 | the same port on the server | For the setup | The setup moves SSH to one random port from 20000 to 59999 and must reach it on that port. It cannot know the port in advance, so the whole range must be open. After the setup, keep only the one port shown on the server's **Overview**. |
| TCP 80 and 443 | the same port on the server | Optional | The server's firewall keeps them open for websites. OpenPanel's services do not need them: their traffic reaches the server through the [agent](/docs/servers/agent)'s own outgoing connection. |
| UDP 41641 | the same port on the server | Optional | The [private network](/docs/network)'s port for direct connections. Without it, your devices still reach the server, sometimes through a relay. |

If port 22 from outside is already taken, forward another outside port (for example 2222) to the server's port 22, and enter that outside port as the **SSH port** in OpenPanel. The 20000–60000 range must go to the same port numbers on the server.

## Why not the DMZ [#why-not-the-dmz]

Many routers can send every incoming connection to one machine, called the DMZ host or exposed host. Do not use it for an OpenPanel server, and do not forward all ports:

- Every port of the machine faces the internet, including during the install, before OpenPanel turns on the server's firewall.
- Anything that later listens on the machine is reachable from the internet at once, whether you meant it to be or not.
- The router stops filtering anything for that machine.

The forwards above are all OpenPanel needs.

## What routers call these settings [#what-routers-call-these-settings]

Menus differ between models and firmware versions. These are the usual names.

| Router | Fixed address for a machine | Port forwarding |
|---|---|---|
| AVM FRITZ!Box | "Always assign this network device the same IPv4 address" (in the device's settings under Home Network) | Port Sharing (under Internet → Permit Access) |
| TP-Link | Address Reservation | Virtual Servers (under NAT Forwarding) |
| Netgear | Address Reservation | Port Forwarding / Port Triggering |
| ASUS | Manually Assigned IP around the DHCP list (under LAN → DHCP Server) | Virtual Server / Port Forwarding (under WAN) |
| Linksys | DHCP Reservations | Single Port Forwarding and Port Range Forwarding |
| Ubiquiti UniFi | Fixed IP Address (in the client's settings) | Port Forwarding |
| OpenWrt | Static Leases (under Network → DHCP and DNS) | Port Forwards (under Network → Firewall) |
| MikroTik | Make Static (on the machine's DHCP lease) | A NAT rule with the action `dst-nat` |
| Your provider's router | Often DHCP reservation or static lease | Often port forwarding, port mapping, NAT or virtual server |

To find the server's address on your network, run this on the server:

```bash
ip -4 addr
```

## Two routers in a row [#two-routers-in-a-row]

Some homes have the provider's modem-router and a router of their own behind it. If your own router's internet address is a private one (for example `192.168.x.x`), forward the ports on both, or put the provider's device in bridge mode so your router gets the public address.

## Check the forwards [#check-the-forwards]

Before you connect the server, check that port 22 answers from outside your network, for example from a phone on mobile data with an SSH app, or from another network:

```bash
ssh -p 22 youruser@203.0.113.10
```

Use your public address and the outside port you forwarded. Many routers do not let you reach your own public address from inside the same network, so test from outside it.

See [Connect a home or office server](/docs/servers/home-server) for the whole flow.