Skip to main content
Dongfang_Li_FTNT
Staff
Staff
September 29, 2023

Technical Tip: Local-in policy VS Virtual IP policy

  • September 23, 2026 at 9:08 AM
  • 0 replies
  • 6520 views

Description

This article describes a scenario where a user wants to block traffic from certain countries from reaching the internal server behind the FortiGate LAN. The IP address belonging to the GEO-blocked country is still able to access the internal server.

 

Below are the configs:    

  • Virtual IP(VIP) and its policy allowing traffic from the Internet interface WAN to LAN, source address 'ALL'.

  • GEO block address for the country to be blocked.

  • Local in policy to block any traffic arriving at the WAN interface from the GEO block address.

Scope

FortiGate.

Solution

According to Packet Life in FortiGate, Destination NAT takes effect at the beginning of packet processing. In the FortiGate kernel, packets are processed in the following order:

 

  1. DNAT (Virtual IP).

  2. Routing.

  3. Policy lookup.

  4. Session helper.

  5. User authentication.

  6. Device identification.

  7. SSL VPN.

  8. Local management traffic.

 

A local policy with an 'action deny' will not deny traffic allowed by a VIP policy because when the local policy takes effect, the VIP policy has already allowed the traffic.  

To resolve the issue.

  1. Create a GEO address object.

  2. Create a firewall policy and select the source address of the 'GEO address' object.

  3. Select the destination VIP.

  4. Select the action deny in the policy.

  5. Put it on top of the VIP allow policy to block the source GEO address.

 

Capture.PNG

 

Notes:

  • The destination address of the deny policy should be set to the VIP address. If set to the normal local server IP address, use CLI to enable match-vip: 'set match-vip enable' in the deny policy.

  • The match-vip option is disabled by default until v7.2.3. In versions above 7.2.3, the option is enabled by default.

  • The 'set match-vip' option is only available if the policy action is set to 'deny'. 

Local-in policy: controls traffic to FortiGate itself.


Examples added:

  • HTTPS access to FortiGate.

  • SSH access.

  • SSL VPN access.

  • SNMP access.


Firewall policy with VIP: controls traffic passing through FortiGate.

The following article explains how to configure blocking VIP access using GEO location:

Technical Tip: How to block VIP access using GEO Location


Local-in policies apply only to traffic destined for the FortiGate itself, such as traffic to an interface IP, while regular firewall policies control traffic that is forwarded through the FortiGate.


When a VIP is configured, the original destination IP can be translated to the mapped internal IP during DNAT processing. Therefore, the firewall policy should be evaluated with the VIP and match-vip behavior in mind.


A local-in policy should not be used as a replacement for a firewall policy when the objective is to control access to an internal server published through a VIP.
To block specific sources from accessing a VIP, create an explicit deny firewall policy above the existing VIP allow policy. This ensures the deny policy is evaluated before the broader allow policy.

If the VIP allow policy uses source address = all, any source not explicitly denied by a higher-priority policy can potentially match the allow policy.

Policy order is important for VIP traffic. FortiGate evaluates firewall policies from top to bottom, and the first matching policy is used. When troubleshooting a VIP access issue, verify the VIP configuration, mapped IP address, mapped port, incoming interface, firewall policy order, source address, destination address, and service configuration.


If a deny policy is not matching the expected VIP traffic, verify whether match-vip is enabled where required and confirm that the policy action is set to deny.

  • The match-vip setting allows a deny policy to match traffic based on the VIP before the destination address is translated to the real server address.

  • Local-in policy troubleshooting should focus on traffic destined to FortiGate interface addresses and enabled administrative or service ports. It does not directly control forwarded traffic to an internal server.


Related documents:

    Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
    Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
    Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT