Introduction
Port forwarding is a technique used to redirect incoming network traffic from one IP address and port number to another IP address and port number. This technique is commonly used in routers and firewalls to allow remote access to devices and services within a private network. However, some users may encounter issues when attempting to set up port forwarding, particularly when using a Unraid 7 server with Docker in bridge mode.
Port Forwarding Setup on OPNsense
To set up port forwarding on OPNsense, follow these steps:
- Log in to the OPNsense web interface.
- Navigate to
Firewall > NAT > Port Forward. - Click the
Addbutton to create a new port forwarding rule. - Enter a descriptive name for the rule in the
Descriptionfield. - In the
Interfacedropdown menu, select the interface that is connected to the Unraid server. - In the
Protocoldropdown menu, select the protocol (TCP or UDP) for the forwarded traffic. - In the
Sourcefield, enter the source port number for the incoming traffic (e.g. 25292). - In the
Destinationfield, enter the destination port number for the incoming traffic (e.g. 25292). - In the
Destinationdropdown menu, select the IP address of the Unraid server (e.g. 192.168.1.111). - In the
Redirect Target IPfield, enter the IP address of the Docker container (e.g. 172.17.0.2). - In the
Redirect Target Portfield, enter the port number for the Docker container (e.g. 25292). - Click the
Savebutton to apply the changes.
Troubleshooting Port Forwarding Issues
If port forwarding is not working for the Unraid 7 server with Docker in bridge mode, consider the following troubleshooting steps:
- Check the firewall rules on the Unraid server to ensure that incoming traffic on the forwarded port is allowed.
- Check the Docker container settings to ensure that the container is listening on the forwarded port.
- Check the NAT settings on the OPNsense firewall to ensure that the port forwarding rule is configured correctly.
- Check the routing tables on the OPNsense firewall and the Unraid server to ensure that traffic can flow between the two devices.
Example Configuration for a Docker Container
The following example shows how to configure a Docker container to listen on a forwarded port:
docker run -d -p 25292:25292/tcp mycontainer:latest- Port forwarding is a technique used to redirect incoming network traffic from one IP address and port number to another.
- Port forwarding can be set up on OPNsense by creating a NAT rule that maps the source and destination ports and IP addresses.
- Troubleshooting steps for port forwarding issues may include checking the firewall rules, Docker container settings, NAT settings, and routing tables.
References
- OPNsense documentation: NAT Rules
- Unraid documentation: Docker Network Settings
- Docker documentation: Publish or expose port