Created on
04-15-2020
12:18 AM
Edited on
08-24-2025
05:18 AM
By
Jean-Philippe_P
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:
config firewall address
edit "restriction_poland"
set type geography
set country "PL" <- Only allows connections from Poland.
next
end
config firewall addrgrp
edit "Geo_restriction_ssl_vpn"
set member "restriction_poland"
next
end
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.
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:
execute update-geo-ip
Wait a few minutes for this to complete. After the update, find FortiGate's current verdict on the location of an IP address:
diagnose firewall ipgeo ip2country x.x.x.x <- The IP.
Alternatively, check with Instant IP Address Lookup (whatismyipaddress.com).
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
Method 2: Local-in-Policy:
Create local-in policies that allow traffic from a specific country and deny it for the 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 "all"
set dstaddr "all"
set service "SSLVPN-Port" <-- Port that is used for SSL VPN connections.
set schedule "always"
set action deny
next
end
Another way to configure a local-in-policy to deny all traffic except from the US is to create a policy with the source address (srcaddr) set to 'US' geo-location and enable the srcaddr-negate option, as shown below. The same requirement can be achieved using a single local-in-policy.
config firewall local-in-policy
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 the 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 the GUI, navigate to System -> Feature Visibility -> Local-In-Policy and select Apply.
As of 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 full guidance on setting up local-in-policy to perform geoblocking, may refer to this article:
Technical Tip: Blocking Geolocations for SSL VPN and management access with a local in policy
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 Library.
Method 3:
Instead of using an outside interface as an inbound interface or SSL-VPN connections, an 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
Note:
As of v7.6.3, the SSL VPN tunnel mode will no longer be supported, and SSL VPN web mode will be called 'Agentless VPN'.
Related articles:
Technical Tip: How to set geolocation address for SSL VPN authentication rule
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.