Description |
This article describes how to restrict HTTPS access from certain countries to the WAN interface by configuring a local-in policy.
This can be useful for reducing the potential attack surface while still retaining WAN-based administrative access. Though it is important to note that best practice is to outright disable HTTP/HTTPS administrative access on any public-facing interfaces where possible (this removes entry points entirely, rather than simply limiting them; see also: Best Practices - Management network). |
Scope | FortiGate. |
Solution |
Note before starting:
It is generally recommended to have either local admin access to the FortiGate (i.e. access via the LAN, VPN, etc.) or serial-console access before configuring local-in policies. This is useful as a backup plan in-case the local-in policy is accidentally misconfigured (e.g. blocking out allowed admins rather than the intended external attackers).
With the above in mind, the steps to configure HTTPS access on the WAN interface with local-in policy filtering are as follows:
Enable HTTPS administrative access on the WAN interface if not already done:
This can be done by editing the WAN interface in the GUI via Network -> Interfaces and enabling HTTPS in the Administrative Access section. In the CLI, this can be enabled via the following commands:
config system interface
Configure the Geography Address object:
The intent here is to use Geography Address objects (which contain country-based mappings of public IP addresses) as a filter for sources that either allowed or disallowed by the local-in policy (see
To do the same task using the CLI, use the following general commands (use the '?' character to see the list of available two-character codes):
config firewall address
Configure the Local-In Policy:
Starting in FortiOS 7.6, local-in policies may be configured in the Web GUI or via the CLI (see also: Technical Tip: Creating a Local-In policy (IPv4 and IPv6) on GUI). In FortiOS 7.4 and earlier, local-in policies may only be configured via the CLI.
With that in mind, use the following commands to configure a local-in policy that blocks access based on the Geography Address object that was created in the earlier step:
config firewall local-in-policy set service 'HTTPS' set action [accept | deny*] <--- See notes below
Notes regarding Local-In Policies:
Testing the Local-In Policy:
To test the HTTPS access after creating the local-in policy, a connection must be attempted from an IP address belonging to a blocked/disallowed country. This requires having a test machine/host in a blocked country or spoofing the source address to a public address that is associated with another country, followed by making a connection using the web browser or with a tool like telnet:
telnet x.x.x.x 443
To observe the local-in policy being assessed on the FortiGate, use the debug flow tool in the CLI:
diagnose debug flow filter dport 443
The following is sample output produced by the debug flow tool that shows traffic being dropped by local-in policy #1.
id=20085 trace_id=1 func=print_pkt_detail line=5746 msg='vd-root:0 received a packet(proto=6, 1.1.1.1:55105->192.168.2.104:443) from wan1. flag [S], seq 2359949110, ack 0, win 65535'
Additionally, it is possible to check for associated log entries under Log & Report -> Local Traffic (filter by service 'HTTPS').
Related documents: |