This article describes how a local-in policy affects traffic matching a Virtual IP (VIP) configuration on the FortiGate firewall.
A FortiGate Firewall configured with local-in policies and a Virtual IP (VIP).
Order of processing: Deciding whether VIP or Local-in policy comes first.
Destination NAT (VIP) takes place before traffic is evaluated by local-in policies, as explained here.
If at least one firewall policy that references the VIP is configured and enabled; then DNAT will take place for the traffic that matches the VIP configuration and firewall policies will decide the outcome of such traffic, not local in policies. Let us evaluate this statement in the following scenarios:
Scenario 1: VIP without port-forwarding i.e. 1:1 DNAT is configured.
If at least one firewall policy is configured referencing the VIP (and the firewall policy is in enabled status), then the traffic will undergo DNAT first and the outcome of the traffic will be based on firewall policies. Local-in policies will not be evaluated.
Note: If the firewall policy is configured for just one service/port:
As long as at least one Firewall policy exists, for one or more services/ports and the policy is in enabled status, traffic for the VIP external IP for all services/ports will be evaluated by Firewall policies, and not by local-in policies (as tested on FortiOS 7.4.4).
Scenario 2: VIP with Port forwarding enabled.
For traffic matching the VIP external IP and VIP external port i.e. for traffic matching the VIP configuration:
If at least one firewall policy is configured referencing the VIP and the firewall policy is in enabled status, (even if the service on the firewall policy does not match the VIP external port), firewall policies will determine the outcome of the traffic matching the VIP configuration, not local-in policies (as tested on FortiOS 7.4.4).
Traffic for ports other than the port(s) forwarded (external port(s)) will be processed by the local-in policies (assuming no other VIPs exist, that could match other ports, such as the example discussed later in this document).
Scenario 3: VIP configured but not referenced in a firewall policy.
Depending on the FortiGate firmware version, and as per the behaviour described here, if firewall considers the configured VIP external IP address as a local IP address, but the VIP is not referenced on any enabled policy, then the traffic will be processed by local-in policies.
Supplementary Scenarios: The use of 'Optional Filters' on VIP:
If Optional Filters are configured on the VIP, the same logic still stands, i.e. if the VIP is referenced in a firewall policy that is in enabled status, if the traffic matches the VIP configuration (either source address or service(s) or both), then firewall policies will decide the outcome of the traffic, not local-in policies.
Note: Service(s) specified imply the VIP external port to be matched by the traffic ingressing the FortiGate.
Example:
Sample configuration to allow only HTTPS traffic to a VIP-mapped IP and block all other services on Interface port3 via local-in-policy:
diagnose debug reset
diagnose debug flow filter saddr 10.245.10.81
diagnose debug flow filter daddr 10.245.15.139
diagnose debug flow filter proto 1
diagnose debug flow trace start 1000
diagnose debug enable
To stop filter:
diagnose debug reset
diagnose debug disable
diagnose debug reset
diagnose debug flow filter saddr 10.245.10.81
diagnose debug flow filter daddr 10.245.15.139
diagnose debug flow filter port 443
diagnose debug flow trace start 1000
diagnose debug enable
To stop the filter:
diagnose debug reset
diagnose debug disable
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.