Learn how to forward ports through a Vultr NAT Gateway using portal or API.
Port forwarding rules allow external traffic to reach specific services on private instances through the NAT Gateway. Configure the external port, internal destination IP, and protocol to enable controlled access for services like SSH, web servers, or custom applications.
Follow this guide to create a NAT Gateway subscription port forwarding rule using the Vultr Customer Portal or API.
Navigate to Products, expand the Network drop-down and select VPC Networks.
Select your target VPC Network with NAT Gateway connectivity.
Scroll to the NAT Port Forwarding section.
Click Add Forwarding Rule.
A panel opens with the following configuration options:
Click Save Changes.
The port forwarding rule applies immediately. Traffic sent to the NAT Gateway's public IP on the external port now forwards to the specified internal instance.
Send a GET request to the List VPCs endpoint to retrieve available VPCs.
$ curl "https://api.vultr.com/v2/vpcs" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
The output displays all VPCs in your account. Note the id field for the target VPC.
Send a GET request to the List NAT Gateway subscriptions endpoint to retrieve the gateway ID. Replace VPC_ID with the ID from the previous step.
$ curl "https://api.vultr.com/v2/vpcs/VPC_ID/nat-gateway" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
The output displays NAT Gateway subscriptions for the VPC. Note the id field for the target gateway.
Send a POST request to the Create NAT Gateway Port Forwarding Rule endpoint. Replace VPC_ID and NAT_GATEWAY_ID with your values. Specify the rule name, protocol (tcp, udp, or both), external port, internal IP address, internal port, and whether the rule is enabled.
$ curl "https://api.vultr.com/v2/vpcs/VPC_ID/nat-gateway/NAT_GATEWAY_ID/global/port-forwarding-rules" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"name": "ssh-to-webserver",
"protocol": "tcp",
"external_port": 2222,
"internal_ip": "10.0.0.10",
"internal_port": 22,
"enabled": true,
"description": "SSH access to web server"
}'
Verify that the response contains the created port forwarding rule with its unique ID, configuration details, and timestamps. Traffic sent to the NAT Gateway's public IP on port 2222 now forwards to the internal instance at 10.0.0.10 on port 22.