7.4. Geolocation

An additional traffic filtering option that is available in IPRule objects is Geolocation. This feature allows filtering of IPv4 and IPv6 addresses for the traffic source and/or destination according to its geographic association. Some IP addresses may not have a known geographic association but these can also be targeted by this feature.

The geolocation feature can be used in two ways:

The following IPRule properties determine geographic filtering:

Geolocation Setup Steps

The steps required for setting up the geolocation feature are as follows:

  1. If the predefined GeolocationFilter objects are not suitable targeted geographic area, define a custom GeolocationFilter area that includes the desired regions.

  2. Use either predefined or custom GeolocationFilter objects as the value for the SourceGeolocation property and/or the DestinationGeolocation property in an IPRule object. The IPRule determines how triggering traffic will be handled.

These configuration components will now be described in more detail.

Selecting a Geographic Area

The value assigned to the SourceGeolocation and/or DestinationGeolocation properties can be one of the following two types:

[Tip] Tip: Using tab completion to list codes

When, for example, creating a new Geolocation object, tab completion can be used to list all available country codes. However, it can be useful to also see the country names associated with codes and this is done by entered a question mark '?' before pressing the TAB key:

System:/> add Geolocation Filter my-gf Regions=?<TAB>
Name     Description
-------  --------------------------------------------
AD       Andorra
AE       United Arab Emirates
AF       Afghanistan
AG       Antigua and Barbuda
AI       Anguilla
AL       Albania
AM       Armenia
AO       Angola
AQ       Antarctica

Updating the Geolocation Database Files

The predefined geolocation regions and their associated IP addresses are defined by two files found on the firewall. One file is for IPv4 addresses and the other is for IPv6 addresses. All cOS Stream software versions come with two default files already installed and activated:

Note that the filetype of these two database files must always be .bin. Clavister will release new versions of these files periodically which can then be uploaded using SCP. They will automatically overwrite their older versions.

Activating Geolocation Files

Once a file is uploaded, it must be activated before it will be used by cOS Stream. This is done with the geoip -activate command but this is only available with the advanced command view :
System:/> geoip -activate=<filename>
A file can be deleted from storage with the -remove option:
System:/> geoip -remove=<filename>
However, it should be noted that -remove operation does not affect the currently activated definitions, it removes the file from which the definitions came.

The current status of all files can be displayed with the -status option:

System:/> geoip -status

The -lookup option can also be used to display the region that corresponds to a given IP address:

System:/> geoip -lookup=<ip-address>

The geoip command and its options are fully described in the separate CLI Reference Guide.

Example 7.4. IP Rule Filtering Using Geolocation

This example will set up an IPRule object that will drop all Internet traffic to a DMZ which is coming from the mythical region of Hackerland. This is done by first creating a GeolocationFilter object that includes only the fictitious regions Hackerland (fictitious ISO code: HA) and Phisherland (fictitious ISO code: PI). An IPRule object will then be defined which will drop all flows that originate from these regions.

In addition, the IPRule will also drop traffic that comes from any IP address that is not known to be associated with a region by enabling the MatchUnknown property in the GeolocationFilter object.

Command-Line Interface

First, create the GeolocationFilter object:

System:/> add GeolocationFilter my_geo_filter
			Regions=HA,PI
			MatchUnknown=Yes

Next, create the IPRule object that uses this filter:

System:/> add IPRule SourceInterface=wan
			SourceNetwork=all-nets
			DestinationInterface=dmz
			DestinationNetwork=all-nets
			Service=all_services
			Action=Deny
			SourceGeoFilter=my_geo_filter
			Name=wan_to_dmz

Note that all-nets includes both all IPv4 and all IPv6 addresses (it is a combination of all-nets-ip4 and all-nets-ip6) so the rule will be applied to both IPv4 and IPv6 source addresses.