Skip to main content
vhitnal
Staff
Staff
May 8, 2020 8:02 AM UTC

Technical Tip: How to block a particular country traffic

  • Jul 28, 2026 7:46 AM UTC
  • 0 replies
  • 31708 views
  • Translate All

Description


This article provides the solution to block a traffic from particular country.

 

Scope

 

FortiGate.

Solution

 

  • Create a geography-based address object.

  • Go to Policy and Objects -> Addresses, select 'Create New' and fill in as below:

Country name example: China.
Type: Geography.
Interface: wan1.

Enable Show in 'Address List' and select 'OK'.

kb_17955_1.png

 

FortiOS v8.0:

2d0db2e5.png


  • Create a WAN-to-LAN policy with the source address as the country for which the geo address object is created. In this case:

Source: China.
Destination: all.

In case any VIP policies exist, keep the policy above VIP policies.

kb_17955_2.png

 

FortiOS v8.0:

79266be3.png


  • However, the incoming traffic will hit the normal VIP policies.

  • Make the changes below in that policy in the CLI.

 

config firewall policy
    edit <firewall policy number> 
        set match-vip enable

 

  • Now, traffic from China will be blocked.

The second solution is to create a local policy for the traffic coming from China. This will only block local-in traffic coming from China to the FortiGate. Select Local-in-policy from the GUI and create a new:

 

spoojary_0-1727216644522.png

 

FortiOS v8.0:

48b7add9.png


In CLI:

 

config firewall local-in-policy
    edit 1
        set intf "port1"
        set srcaddr "China"
        set dstaddr "all"
        set service "ALL"
        set schedule "always"
    next
end

 

To add more countries, create a Geography address for each one, include them in an address group, and then add the address group to the local-in-policy as shown below:

 

config firewall local-in-policy
    edit 1
        set intf wan1
        set srcaddr ?
        *name Address name.
        BLOCK_CHINA address
        BLOCK_IRAQ address
        BLOCKED_COUNTRIES addrgrp
        set srcaddr BLOCKED_COUNTRIES
        set dstaddr all
        set service ALL
        set schedule always
    next
end


Related articles:

Technical Tip: DENY Policy for Virtual IP Firewall Policy

Technical Tip: How to block by country or geolocation

    Risk and Resilience in the Age of AI. An OT Thought Leadership Summit for Houston's Critical Infrastructure Leaders. Date: Thursday, December 3, 2026. Time: 8:30 am - 1:30 pm (CT). Location: The Westin Houston, Memorial City | 945 Gessner Road, Houston, TX 77024