Introduction
Port forwarding is a router function that allows you to redirect incoming internet traffic from a specific port to a particular device on your local network. Without this configuration, devices inside the network are protected by a firewall and are not visible from the outside. Using port forwarding, you can, for example, enable access to a home server, gaming server, security camera, or file sharing service from anywhere in the world. This guide will walk you through all the setup steps using typical routers and operating systems.
Requirements
Before you begin, make sure you have:
- Access to the router: The router's IP address (usually 192.168.1.1 or 192.168.0.1), login, and password. Defaults are often
admin/adminor listed on a sticker. - Local IP address of the target device: The computer or other device to which you want to forward the port.
- Service information: The port number (e.g., 25565 for Minecraft) and protocol (TCP, UDP, or both). Check your application's documentation.
- The device must be powered on and connected to the network.
- Recommended: Reserve a static IP for the target device in the router's DHCP settings to prevent the address from changing after a reboot.
💡 Tip: If you don't know your router's IP, on Windows run
ipconfigin the command prompt and look for "Default Gateway." On Linux/macOS, useip route | grep defaultornetstat -rn.
Step-by-Step Instructions
Step 1: Determine the Device's Local IP Address
On the device that will receive connections (e.g., a computer running a server), you need to find its current local IP address. This is the address within your home network, such as 192.168.1.100.
For Windows:
- Press
Win + R, typecmd, and press Enter. - In the command prompt, run:
ipconfig - Find the section for your network adapter (Ethernet or Wi-Fi) and copy the "IPv4 Address" value. For example:
192.168.1.100.
For Linux (Ubuntu, Debian, etc.):
- Open the terminal.
- Run one of the following commands:
orifconfigip addr show - Find the interface (e.g.,
eth0orwlan0) and theinetaddress (notinet6). That is your IP.
For macOS:
- Open Terminal from Utilities.
- Run:
(for Wi-Fi,ifconfig en0en0might been1depending on the model). - Look for
inetafteren0:.
Write down this address—you will need it in Step 4.
Step 2: Log into the Router's Web Interface
- Connect to your home network (via Wi-Fi or cable) from the device you will use for configuration.
- Open any browser (Chrome, Firefox, Edge).
- In the address bar, enter the router's IP address. Most commonly it is
192.168.1.1or192.168.0.1. If that doesn't work, check the sticker on the router or use the gateway found in Step 1. - Press Enter. A login page should appear.
- Enter the login and password. Defaults are often:
- Login:
admin - Password:
adminorpasswordIf you changed the password, use your own. If you forgot it, you may need to reset the router to factory settings (press the Reset button on the case for 10 seconds).
- Login:
After logging in, you will see the router's control panel.
Step 3: Find the Port Forwarding Section
Router interfaces vary by manufacturer and model. The port forwarding section may be named differently:
- Port Forwarding
- Virtual Server
- NAT Forwarding
- Перенаправление портов (Russian for Port Forwarding)
- Services
- Security → Port Forwarding
It is usually located in menus such as:
- WAN / Internet
- Advanced / Дополнительно
- Security / Безопасность
- LAN / Local Network
If you cannot find it, search the documentation for your model (e.g., "TP-Link Archer C7 port forwarding") or online.
Step 4: Add a Port Forwarding Rule
- In the port forwarding section, click the Add (Добавить), Create (Создать), or
+button. - Fill in the form fields. Exact names may differ, but the concept is the same:
- External Port / WAN Port / Внешний порт: The port that will be open from the internet. For example,
25565for Minecraft. You can specify a range if multiple ports are needed. - Internal Port / LAN Port / Внутренний порт: The port on the target device. Often it matches the external port, but it can differ if the service on the device listens on a different port.
- Protocol / Протокол: Select
TCP,UDP, orBoth(both). For accuracy, check your application's documentation. For example, Minecraft uses TCP, while some games use UDP. - Internal IP Address / LAN IP / Внутренний IP адрес: Enter the local IP address you determined in Step 1 (e.g.,
192.168.1.100). - Description / Имя (optional): A brief description, like "Minecraft Server," to avoid confusion with the rule.
- External Port / WAN Port / Внешний порт: The port that will be open from the internet. For example,
- Click Save (Сохранить) or Apply (Применить).
- The router may prompt you to reboot. Do so if required.
⚠️ Important: Ensure the service (server) is running on the target device and listening on the specified internal port. Otherwise, the forwarding will work, but connections will not be accepted.
Step 5: Set Up a Static IP for the Target Device (Recommended)
If the device's IP address is assigned dynamically (via DHCP), it may change after a router or device reboot, breaking the port forward. To avoid this, reserve the address.
Method A: Reservation in the Router (Preferred)
- In the router's web interface, find the DHCP or Local Network → ARP or DHCP Clients section.
- Locate your device in the list (by name or MAC address).
- Click "Reserve" (Резервировать) or "Add" and bind it to a specific IP (the one you used in the port forward rule).
- Save the settings.
Method B: Configure a Static IP on the Device
- Windows: Control Panel → Network and Internet → Network and Sharing Center → Change adapter settings → Right-click the adapter → Properties → IPv4 → Specify an IP address, subnet mask (usually 255.255.255.0), gateway (router's IP), and DNS (can be the gateway).
- Linux: Edit the interface configuration file (e.g.,
/etc/netplan/01-netcfg.yamlfor Ubuntu) or usenmcli. - macOS: System Preferences → Network → Advanced → TCP/IP → Configure IPv4: Manually.
Ensure the static IP is in the same subnet as the router (e.g., 192.168.1.x) and does not overlap with the DHCP pool to avoid conflicts.
Step 6: Test the Port Forward
- Ensure the service (e.g., a game server) is running on the target device.
- From a computer or phone connected to a different network (not your home network, e.g., mobile data), try connecting to your external IP address and port.
- To find your external IP, visit a site like 2ip.ru or similar.
- Use online port scanners to check if the port is open:
- canyouseeme.org
- yougetsignal.com/tools/open-ports/ Enter the external port and click Check. If the port is open, the service should respond.
- If the check shows the port is closed, recheck all settings, ensure the firewall on the device is not blocking the port, and verify your ISP is not blocking it (sometimes ISPs block specific ports).
Verification
After successful port forwarding, you should be able to:
- Connect to the service from any device on the internet using your external IP address and the specified port.
- For example, for a game server: in the game, add a server with the address
your_external_IP:port. - For a web server: open
http://your_external_IP:portin a browser.
If the connection fails, refer back to the "Troubleshooting" section.
Troubleshooting
The Port Remains Closed After Configuration
- Cause: The service on the device is not running or is listening on a different port.
- Solution: Start the server and check which port it uses (e.g., in a configuration file).
- Cause: Incorrect local IP address in the rule.
- Solution: Recheck the device's IP. If the IP is dynamic, set up a static IP or reservation.
- Cause: The firewall on the device is blocking the port.
- Solution: Add a firewall rule to allow incoming connections on the required port (TCP/UDP). On Windows: Windows Defender Firewall → Advanced Settings → Inbound Rules.
- Cause: The ISP is blocking the port (especially common ones like 25 for SMTP).
- Solution: Change to a different, unblocked port or contact your ISP.
Cannot Access the Router's Web Interface
- Cause: Incorrect router IP.
- Solution: Check the gateway via
ipconfigorip route.
- Solution: Check the gateway via
- Cause: Incorrect login/password.
- Solution: Reset the router to factory settings (hold the Reset button for 10 seconds). After resetting, use the default credentials from the sticker.
- Cause: The router is not responding.
- Solution: Reboot both the router and your device.
No External Access After Setup, but Local Works
- Cause: NAT loopback is not supported by the router. Some routers do not allow connecting to their own external IP from inside the network.
- Solution: Test the connection from an external network (e.g., using mobile data).
- Cause: Double NAT (if you have multiple routers).
- Solution: Configure port forwarding on the main router connected to the ISP, and on the secondary router if necessary.
Port Scans Open, but Service Does Not Respond
- Cause: The service is configured to listen only on localhost (127.0.0.1) or a specific IP, not on all interfaces.
- Solution: Configure the service to listen on 0.0.0.0 (all interfaces) or on the device's local IP.
- Cause: Incorrect protocol.
- Solution: Ensure the correct protocol (TCP/UDP) is selected in the rule. Some services require both.