Created on
‎05-08-2007
12:00 AM
Edited on
‎09-10-2025
10:16 PM
By
Jean-Philippe_P
Description |
This article describes port forwarding using FortiGate Virtual IPs. |
Scope |
FortiGate. |
Solution |
To forward TCP or UDP ports received by the FortiGate external interface to an internal server, follow two steps:
This example describes how to configure port forwarding to allow RDP access to an internal server on port 3389. To add a virtual IP that forwards RDP packets, follow the steps below.
All that remains is to define a firewall policy that accepts RDP traffic from the Internet and forwards it to the internal server.
To add a firewall policy with a virtual IP:
Note: NAT is not mandatory when creating a VIP. ONLY if the behavior wants to be changed with the source and specific port, like in the example provided above. Sometimes NAT needs to be enabled for VOIP traffic
The port range can be added for port forwarding in the virtual IP as below:
Make sure to add this port range as a service in the firewall policy as well.
Note: If the 'External service port' and 'Map to IPv4 port' are different, both ports must be specified in the 'Service' field of the firewall policy (if it is not set to 'any').
config firewall vip edit "Test" set extip 20.20.20.20 next end
To verify traffic hitting and using the correct policy, the following debugs can be used:
Packet Sniffer:
diagnose sniffer packet any ' host a.a.a.a and port bb ' 4 0 l <----- a.a.a.a is the source IP and port bb is the NAT port.
Debug Flow:
diagnose debug disable
diagnose debug flow trace stop
diagnose debug flow filter clear
diagnose debug reset
diagnose debug flow filter addr x.x.x.x <----- x.x.x.x is the source IP.
diagnose deb fl sh ip en
diagnose debug flow show function-name enable
diagnose debug console timestamp enable
diagnose debug flow trace start 999
diagnose debug enable
To stop the debug:
diagnose debug disable
Security Best Practices:
Note: There was a change made to the behavior of the IP Pool and VIP after upgrading FortiOS to v6.4, v7.0, v7.2, and v7.4. For more information, see this article: Technical Tip: IP pool and virtual IP behavior changes in FortiOS 6.4, 7.0, 7.2, and 7.4. Ensure that the service's external port and the FortiGate administrative access port are configured to use different ports. This helps avoid port conflicts and ensures secure and uninterrupted access to both services
Related article: Technical Tip: Traffic not flowing via interface IP after configuring the VIP. |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.