Technical Tip: How to block a particular country traffic
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'.

Â
FortiOS v8.0:

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.

Â
FortiOS v8.0:

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:
Â

Â
FortiOS v8.0:

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:
