Understanding NS1's GeoFilters

Real time DNS traffic steering enhances your user’s online experience. NS1’s Filter Chain™ technology offers traffic steering capabilities including those that leverage user location, current traffic conditions on the internet, server availability, and datacenter utilization. This article focuses on the Geo Filters, our location based traffic steering filters. For more information on all available filters and a description of what each filter is designed to do, please see our Filter Chain article.

An important benefit of NS1’s technology is our support of EDNS client subnet information. This means NS1’s geolocation filters can route users based on their location and not simply the location of their DNS resolver. It enables our DNS platform to know more accurately where the user is located and to use that information to route the user accordingly.

The most common application of Geo Filters is to connect users to the point of presence that is geographically closest to them. Geo Filters are used for other purposes as well, such as ensuring users located in certain countries are routed to specific datacenters only. Geo Filters can even be used to block connections that come from specific countries or regions. Because we have such a feature-rich set of geographic routing capabilities, it is helpful to understand what they are as well as how and when to use them. There are two basic types of Geo Filters: Geo Targeting and Geo Fencing.

Geo Targeting filters provide turn-key proximity-based routing using location metadata such as region, country, state, or even latitude and longitude coordinates. When a request hits NS1’s nameservers, we reference our GeoIP database to determine the location of the end user. In real-time NS1 DNS calculates the user’s proximity to your datacenters, ensuring every end user is routed to the nearest datacenter.

The following GEOTARGET filter options are available. Each provides a different degree of routing granularity:

  • GEOTARGET_REGION, to sort users based on their origin world region.
  • GEOTARGET_COUNTRY, to sort users based on their origin country. 
  • GEOTARGET_LATLONG, to sort users based on their geographic lat/long.

Geo Fencing filters look at requests coming from specific regions, countries, or states, and by cross referencing the IP of the requester with NS1’s advanced GeoIP database, route and restrict those end users to the servers or datacenters of your choosing. This allows you to keep user data within specific countries or direct users through specific in-country CDNs.

The following GEOFENCE filter are available, also providing different levels of granularity:

  • GEOFENCE_REGION, to sort users based on their origin world region.
  • GEOFENCE_COUNTRY, to sort users based on their origin country.

Unlike the GEOTARGET filters, the GEOFENCE filters look for users from the identified REGION(s) or COUNTRY(s) and send those users to the identified address. A user’s origin location MUST match the GEOFENCE filter target region(s) or country(s) in order to be routed to the endpoint identified by the filter. All other users may or may not receive an answer to the query based on the availability of alternative endpoint locations.

Geo Targeting Example:  Routing Users to the Closest Datacenter

This example will walk you through the steps of adding the appropriate metadata and filters into your Filter Chain setup in NS1’s portal. Filter Chains use the metadata to make routing decisions.

Step 1: Add a Geotarget Filter from the list on the right to the Active Filters chain on the left. In this example, we’ve chosen the Geotarget Country filter.

Step 2: Click the server icon to the right of the answer, example: 123.54.56.5 DC-1, to add metadata.


Step 3: Add regions or countries, depending on the filter you are using. In this example, we are using GEOTARGET_COUNTRY and have selected a variety of North American countries for the answer, 123.54.56.5 DC-1.


Step 4:  Repeat Steps 2 and 3 for the answer 32.251.25.2 DC-2. For the GEOTARGET_COUNTRY filter data, you can add in any location you like. The filter needs a starting point to determine which answer is geographically closest to you. Any requests from locations not included in the GEOTARGET_COUNTRY filter will be routed to the closest answer based on the user’s location.

After completing step 4, our example configuration has a GEOTARGET_COUNTRY filter with a few different North American countries for answer 123.54.56.5 DC-1 and a location of your choice for answer 32.251.25.2 DC-2. Users from identified countries will be routed based on the answer for their country. Users from countries not specifically identified by the filter’s metadata will be routed to the closest answer to their location.

Geo Fencing Example:  Routing Users to Specific Datacenters

This example will walk you through the steps of adding the appropriate metadata and filters into your Filter Chain setup in NS1’s portal. Filter Chains use the metadata to make routing decisions.

Step 1: Add a Geofence Filter from the list on the right to the Active Filters chain on the left. In this example, we are using the Geofence Country filter.


Step 2: Click the server icon to the right of the answer, example: 32.251.25.2 DC-2, to add metadata.


Step 3: Add regions or countries, depending on the filter you are using. In this example, we are using GEOFENCE_COUNTRY and have selected a variety of North American countries for the answer, 32.251.25.2 DC-2.

Our example configuration now has a GEOFENCE_COUNTRY filter with a few different predetermined countries for our domain answer2.ns2example.com. Anyone from the selected countries will be routed to the 32.251.25.2 DC-2 answer appropriately. All other users will be routed to another location based on their respective geolocation.

The Difference Between GEOFENCE and GEOTARGET Filters

A GEOTARGET filter works as a preferred option. The filter reorders DNS answers based on the user’s detected geolocation and sends the appropriate answer based on the user’s origin.

A GEOFENCE filter works like a walled (fenced) garden. Only those identified by the metadata as allowed receive an endpoint answer to the query. This filter can be configured, for example, to allow specific countries within a region to get a different answer than all the other countries in that region. The filter removes DNS answers from the answer pool based on configured metadata and the user’s origin IP address.

When setting up filters, select either the GEOFENCE or GEOTARGET filter. They cannot be used in the same Filter Chain.

Why can’t we use Region or Country for both GEOTARGET and GEOFENCE?
Each filter in the Filter Chain has associated metadata, countries or regions, for each of the DNS answers. If you have a GEOTARGET_COUNTRY and a GEOFENCE_COUNTRY in the same filter chain with the same metadata, the DNS answers you want to provide for the GEOTARGET answers could potentially be stripped out of the available answers by the GEOFENCE filter.

What if I need to use both?
A good workaround for this situation is to use domain CNAME records and the following steps to setup a Filter Chain using both GEOFENCE and GEOTARGET filters.

Geo Work Around Example: Using Both GeoTarget and GeoFence

This example will walk you through the workaround steps of adding both a Geo Target and a Geo Fence Filter Chain to the same domain. Create a CNAME for the domain, add the filter to your Filter Chain setup in NS1’s portal, then associate the correct metadata as shown in the following steps. Filter Chains use both the metadata and the different filter types to make routing decisions.

Step 1: Setup your domain, for example: ns2.example.com. Include 2 A records for the domain: answer1.both.ns2.example.com and answer2.both.ns2.example.com.

NOTE: A records in the portal can contain up to 100 IP address answers for each A record.


Step 2: Create a Filter Chain for the CNAME both2.ns2.example.com, and add the following filters in order: UP > GEOFENCE_COUNTRY > SELECT_FIRST_N=1.

Step 3: Click the server icon to the right of the answer, in this case, answer2.both.ns2.example.com, to add metadata.

Step 4: Add regions or countries, depending on the filter you are using. In this example, we are using GEOFENCE_COUNTRY and have China and Japan fenced off for answer2.both.ns2.example.com. Leave the metadata fields blank for answer1.both.ns2.example.com.

This graphic shows China and Japan are fenced off in answer2.both.ns2.example.com metadata.



By fencing off China and Japan, users from these countries will be sent to answer2.both.ns2.example.com and all other countries will be answered by the remaining DNS answer: answer1.both.ns2.example.com. The remaining steps will walk you through setting up the Geotarget Country Filter Chain.

Step 5: Select the A record  answer1.both.ns2.example.com and add the following filters in order: UP > GEOTARGET_COUNTRY > SELECT_FIRST_N=1.



Step 6: Click the server icon to the right of the answer, example: answer1.both.ns2.example.com, to add metadata.

Step 7: Populate the Filter Chain meta data so that all Eastern Asia countries, except China and Japan, will be GeoTargeted into answer1.both.ns2.example.com and China and Japan will be GeoFenced into answer2.both.ns2.example.com.

  1. Set the Up filter to ‘True’.

  2. Set the Country filter to all Eastern Asia countries EXCEPT China and Japan.

  3. Set the Select First N filter to ‘1’.

Our example configuration now has GEOFENCE_COUNTRY and GEOTARGET_COUNTRY filters with Eastern Asia countries for our domain both2.ns2.example.com. Anyone from the selected countries will be routed to the appropriate answer.

NS1 has ASN and IP Prefix filters to route users based on these criteria as well. You can find that information in the Filter Chain article. If you have any questions about implementing your own Filter Chains, contact NS1 and we’ll be happy to help!

Back to All Resources

Request a Demo

Contact Us

Get Pricing