Description
The article describes how to restrict SSL VPN connectivity from certain countries. By default, the SSL VPN is accessible to all public IP addresses from the Internet. Still, it is possible to restrict access to a specified set of allowed IP addresses using IP/Subnet Address Objects and Geo-IP Address objects.
Scope
FortiGate.
Solution
There are three methods to block the connection: the source address under VPN SSL SETTINGS, local-in-policy, and regular policies when moving the listening interface to a loopback.
The Restrict Access (aka source-address) configuration can be modified without disrupting existing SSL VPN connections, though only if the modifications continue to allow a given user's source address to connect. For example:
- If the Restrict Access option is set to Limit access to specific hosts, and the Hosts include Canada and USA Geography Address objects, then users in Canada and the USA can connect to the SSL VPN.
- If Canada is then removed from this config and the changes are applied, any connected Canadian Users will be disconnected (since they have become disallowed).
- On the other hand, adding a Mexico Geography Address object to the allowed hosts will not disrupt any existing connections for USA/Canadian VPN users.
- Configure the firewall address with the geography type.
config firewall address
edit "restriction_poland"
set type geography
set country "PL" <- Only allows connections from Poland.
next
end
- Configure the firewall address group.
config firewall addrgrp
edit "Geo_restriction_ssl_vpn"
set member "restriction_poland"
next
end
- Configure the firewall address group as the source-address under SSL VPN settings.
config vpn ssl settings
set servercert "Fortinet_Factory"
set tunnel-ip-pools "SSLVPN_TUNNEL_ADDR1"
set tunnel-ipv6-pools "SSLVPN_TUNNEL_IPv6_ADDR1"
set port 444
set source-interface "wan1"
set source-address "Geo_restriction_ssl_vpn"
end
From the GUI.
- Go to Policy & Objects -> Addresses, select 'Create new', select 'Geography' as the address Type, and select the country to allow.

- After creating the country on the addresses, the same must be mapped on the firewall SSL VPN settings to restrict access. Go to VPN -> SSL VPN Settings. Under 'Restrict Access', select 'Limit access to specific hosts' and add the address object created in Step 1 to allow access to the VPN.

- If the original public source IP is not visible to FortiGate, the geo-ip location-based restriction will not work.
- If there are SSL VPN authentication rules that have source-address defined as 'all', the globally configured source-address will not work.
In the preceding example, users from Poland are permitted to connect to this SSL VPN. However, if it is also necessary to add a few individual IP addresses/ranges from an undefined Country/Region, the address objects can be included under SSL VPN settings as shown below.
After making this change, if there are still hits from different IPs from unintended countries, refer to the information and steps below:
- Check the FortiGate's geo-ip database. First update the geo IP database on FortiGate first with the following command:
execute update-geo-ip
Wait a few minutes for this to complete. After update, find FortiGate's current verdict on location of an IP address:
diagnose firewall ipgeo ip2country x.x.x.x <- The IP.
Alternatively, check with Instant IP Address Lookup (whatismyipaddress.com)
- If an IP address is blocked in global SSL-VPN configuration but still has connection attempts logged, the authentication rule may have a different address group configured. See the article SSL VPN source-interface setting in authentication rule taking precedence. If a specific source-address in authentication-rule is overriding the intended global rule, remove the source-address configuration by unsetting source-interface in authentication-rule.
config vpn ssl settings
config authentication-rule
edit <index>
unset source-interface
next
end
end
Alternatively, reconfigure the authentication-rule to allow or block the required source address.
config vpn ssl settings
config authentication-rule
edit <index>
set source-interface "wan1" <----- Interface specified in SSL VPN.
set source-address "Allow US IPs Only" <----- Just use the country desired to allow.
set source-address-negate disable
set groups "SSLVPN_users" <----- This is the group in the policy of SSL VPN.
set portal "full-access"
next
end
end
- After these changes, it will not be possible to see any other attempt from outside the US in the VPN events logs. Another method would be to use local-in-policy to block any attempts to connect to SSL VPN.
Method 2: Local-in-Policy:
Create local-in policies that allow traffic from a specific country and denies for rest of them:
config firewall local-in-policy
edit <index of allow policy>
set intf "wan1"
set srcaddr "Allow US IPs Only"
set dstaddr "all"
set service "SSLVPN-Port" <- Port that is used for SSL VPN connections.
set schedule "always"
set action accept
next
edit <index of deny policy>
set intf "wan1"
set srcaddr "Allow US IPs Only"
set srcaddr-negate enable <-- Negates the Source group, In this scenario means any country IP other than US
set dstaddr "all"
set service "SSLVPN-Port" <-- Port that is used for SSL VPN connections.
set schedule "always"
set action deny
next
end
Note:
The Policies are processed in configuration order 'top to bottom' and processed according to the first match. To reorder a local-in-policy, use the move command, see Technical Tip: How to move the order local-in policy FortiGate
config firewall local-in-policy
move 2 before 1
end
For read-only local-in-policy visibility in GUI, navigate to System -> Feature Visibility -> Local-In-Policy and select Apply.
Starting from v7.6.0, Local-in Policy can also be configured in the GUI. Refer to this document for reference: Technical Tip: Creating a Local-In policy (IPv4 and IPv6) on GUI
For SSL VPN, VPN configuration, and port used in this article, more information is available via this link: SSL VPN best practices | FortiGate / FortiOS 7.4.1 | Fortinet Document Librar
Method 3:
Instead of using an outside interface as an inbound interface or SSL-VPN connections, and administrator may configure a loopback with a private IP following the example in Technical Tip: SSL VPN connection to a Loopback Interface using Virtual IP and use a firewall policy and Virtual IP to forward SSL-VPN connection attempts to the loopback interface.
With this method, the administrator can use a regular firewall policy to filter inbound connections.
config firewall policy
edit <index>
set name "SSL-INBOUND-RULE"
set srcintf "wan1"
set dstintf "Loop1"
set action accept
set srcaddr "Allow US IPs Only"
set dstaddr "SSLVPN-VIP"
set schedule "always"
set service "ALL"
set logtraffic all
next
end
Related article:
Technical Tip: How to set geolocation address for SSL VPN authentication rule