---
title: Geosite/Geoip Configuration Guide
slug: routing/geositegeoip-configuration-guide
description: Geosite/Geoip Configuration Guide
createdAt: 2025-12-03T02:28:42.989Z
---

## <font color="#1d50a2">Introduction</font>

GeoSite/GeoIP is a routing and policy control feature based on geographical location. By leveraging precise geolocation databases, it delivers intelligent, flexible, and efficient traffic management solutions. Utilizing global IP address allocation information and domain name geolocation data, GeoSite/GeoIP enables fine-grained control over network traffic.

The advantages of GeoSite/GeoIP include accurate geographical location identification, flexible traffic policy configuration, efficient database query mechanisms, and robust access control capabilities. Compared to traditional IP range-based control methods, GeoSite/GeoIP offers greater precision, enhanced flexibility, easier maintenance, and more granular network management capabilities.

## <font color="#1d50a2">Geosite/Geoip Configuration</font>

### <font color="#1d50a2">Loading dat file</font>

| **Operation**                       | **Command**                         | **Description**                                                                                                                                            |
| ----------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enter the system configuration view | **configure terminal**              |                                                                                                                                                            |
| Load the geosite.dat file           | **geosite load \{default\|string}** | The device will initially load the default dat file, and when an update is needed, string the full path of the file containing the latest geosite.dat file |
| Load geoip.dat file                 | **geoip load \{default\|string}**   | The device will initially load the default dat file, and when an update is needed, string the full path of the file containing the latest geoip.dat file   |

### <font color="#1d50a2">Perform Geosite/Geoip Query</font>

| **Operation**                       | **Command**                 | **Description**                                                                                                                       |
| ----------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| Enter the system configuration view | **configure terminal**      |                                                                                                                                       |
| Query geosite based on domain       | **geosite lookup** *string* | *string*：Fill in the domain name to be queried, and all country codes corresponding to the domain name will be displayed              |
| Query geoIP based on IP             | **geoip lookup** *A.B.C.D*  | *A.B.C.D*:Fil&#x6C;*&#x20;in the IP address that needs to be queried, and the country code corresponding to the IP will be displayed* |

### <font color="#1d50a2">Configure ACL based geosite/geoip</font>

| **Operation**                                        | **Command**                                              | **Description**                                                               |
| ---------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------- |
| Enter the system configuration view                  | **configure terminal**                                   |                                                                               |
| Enter ACL configuration view                         | **access-list \{L3\|L3V6} \<string> \{ingress\|egress}** | Enter ACL configuration view                                                  |
| Configure the geosite field that needs to be matched | **geosite \<string>**                                    | String：The country code corresponding to the geosite that needs to be matched |
| Configure the geoIP field that needs to be matched   | **geoip \<string>**                                      | string：The country code corresponding to the geoIP that needs to be matched   |

### <font color="#1d50a2">Configuring PBR based Geosite/Geoip</font>

| **Operation**                                         | **Command**                       | **Description**                                                                                  |
| ----------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------ |
| Enter the system configuration view                   | **configure terminal**            |                                                                                                  |
| Create a policy route and enter the policy route view | **pbr-map \<name> seq \<number>** | name：Specify policy name<br />nubmer：                                                            |
| Configure the geosite field that needs to be matched  | **geosite \<string>**             | string：Strategy ID, with a value range of 1-700. The smaller the number, the higher the priority |
| Configure the geoIP field that needs to be matched    | **geoip \<string>**               | string：The country code corresponding to the geoIP that needs to be matched                      |

## <font color="#1d50a2">Display and Maintenance</font>

| **Operation**                                        | **Command**              |
| ---------------------------------------------------- | ------------------------ |
| Display the currently loaded geosite.dat information | **show geosite summary** |
| Display the currently loaded geoip.dat information   | **show geoip summary**   |

## <font color="#1d50a2">Example of Geosite/Geoip Configuration</font>

**Network Requirements**

The enterprise network requires the device to enforce geographic location-based traffic restrictions, such as blocking access to all services located in the US. This can be achieved by configuring ACL rules with GeoSite/GeoIP to block all traffic meeting either of the following conditions from being forwarded through the specified public network port (Ethernet2 in the diagram):

1\. Packets containing domains whose GeoSite country code is US.

2\. Packets without domain information but whose destination IP's GeoIP country code corresponds to US.

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/qkcpmbyxsLRRh4tN0eoVW-20251203-063253.png" size="70" width="643" height="405" position="center" showCaption="false"}

**Procedure**

```plaintext
sonic(config)# access-list L3 test egress
sonic(config-L3-acl-test)# rule 1 geoip US packet-action deny
sonic(config-L3-acl-test)# rule 2 geosite US packet-action deny
sonic(config-L3-acl-test)# exit
sonic(config)# interface ethernet 2
sonic(config-if-2)# acl test
```

