Terraform provider reference / resources / router_port_forward
fiberax_router_port_forward (Resource)
One port forward of a ROUTER: traffic arriving on a public port of the router is sent to a server inside one of its private networks.
A forward is a resource of its own, addressed by its number on the router (priority), exactly like fiberax_router_firewall_rule. Forwards are checked in ascending number order and the first matching one wins; two forwards with overlapping public ports are both accepted, and the lower number applies - neither the platform nor the provider checks the overlap.
The public port may not cover the router's management port, the reserved port 55443 or the port of its WireGuard or OpenVPN tunnel (even a switched-off one), and the target must lie inside a private network attached to this router and must not be the router itself.
Example Usage
# Port forwards of a ROUTER: a public port of the router is sent to a server
# inside one of its private networks. The target must be inside a network
# attached to the router and must not be the router itself; the public port
# must not cover the router's management port, the reserved port 55443 or the
# port of its VPN tunnel.
resource "fiberax_router_port_forward" "ssh_to_app" {
server_id = fiberax_server.router.id
public_port = "2222"
target = "10.0.0.5" # the private address of the app server, one address, no prefix
target_port = "22" # a single port on the target
source = "203.0.113.0/24" # who may use the forward; omit for anyone
description = "ssh to the app server"
}
# A range on the same port, both protocols. target_port omitted: the traffic
# keeps the port it arrived on.
resource "fiberax_router_port_forward" "game" {
server_id = fiberax_server.router.id
public_port = "27015-27020"
protocol = "tcp_udp"
target = "10.0.0.7"
description = "game server"
}
Schema
Required
public_port(String) Port on the router's public address AS TEXT: a number, a comma-separated list or a range WITH A DASH (2222,8080,8443,10000-20000), up to 200 characters.server_id(Number) The router the forward belongs to. Changing this field recreates the resource.target(String) IPv4 address of the server inside a private network of this router, without a prefix.
Optional
description(String) A note on the forward, up to 120 characters, without control characters.enabled(Boolean) A disabled forward stays on the router and does nothing. Enabled by default.priority(Number) Forward number, 2000 to 999000; lower numbers are checked first. Omit it and the platform takes the LOWEST free number of the row 2000, 2010, 2020, ... Cannot be changed on an existing forward: a different number recreates the resource.protocol(String)tcp,udportcp_udp. Defaults totcp, and the default is declared here so that it is visible in the plan.source(String) IPv4 address or IPv4/prefix allowed to use the forward. Not set means anyone.target_port(String) A single port on the target (a list or a range is not accepted here). Not set means the same port the traffic arrived on.
Read-Only
editable(Boolean) False when the forward carries conditions this API cannot express (extrais non-empty): it can only be read and deleted.extra(List of String) Conditions outside this API's model, in the router's own words. Empty for forwards created through Terraform.id(Number) Forward number on the router - the same value aspriority.interface(String) Router interface the forward listens on. Read-only: a new forward always listens on the public interface; not set on older forwards means any.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
# The import ID is the router's server ID and the forward number, separated by a comma. terraform import fiberax_router_port_forward.ssh_to_app 11102,2000
Generated from the provider schema for version 0.11.0. How to install the provider: Terraform provider.