---
title: Geosite/Geoip Configuration
slug: routing/geositegeoip-configuration
description: Geosite/Geoip Configuration
createdAt: 2025-12-04T03:35:07.372Z
---

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

### <font color="#1d50a2">show geosite summary</font>

**\[Command]**
**show geosite summary**

**\[Purpose]**
Display the currently loaded geosite.dat information, including the loaded dat file, country\_comde statistics, domain\_rule statistics.

**\[View]**
System view

**\[Use Cases]**

```plaintext
sonic# show geosite summary
Geosite Statistics:
  Use default geosite data
  Total Country Codes: 1403
  Total Domain Rules : 108358
```

### <font color="#1d50a2">show geoip summary</font>

**\[Command]**
**show geoip summary**

**\[Purpose]**
Display the currently loaded geoip.dat information, including the loaded dat file, country\_comde statistics, and ipv4/v6 statistics.

**\[View]**
System view

**\[Use Cases]**

```plaintext
sonic# show geoip summary
Geoip Statistics:
  Use default geoip data
  Total Country Codes: 260
  Total IPv4 counts: 627125
  Total IPv6 counts: 655079
```

### <font color="#1d50a2">geosite load *string|default*</font>

**\[Command]**
**geosite load *string|default***

**\[Purpose]**
Used to load and update the geosite.dat file. You can choose to load the default dat file or specify a dat file in a specific path as the updated dat file.

**\[View]**
System configuration view

**\[Notes]**
Please note that after executing this command, you need to reload the device to ensure that the dat file is successfully loaded. If the configuration needs to be saved, please execute write to save the configuration.

**\[Use Cases]**

```plaintext
sonic(config)# geosite load default
please config reload to make load effective
sonic(config)# reload
```

### <font color="#1d50a2">geoip load *string|default*</font>

**\[Command]**
**geoip load *string|default***

**\[Purpose]**
Used to load and update the geoip.dat file. You can choose to load the default dat file or specify a dat file in a specific path as the updated dat file.

**\[View]**
System configuration view

**\[Notes]**
Please note that after executing this command, you need to reload the device to ensure that the dat file is successfully loaded. If the configuration needs to be saved, please execute write to save the configuration.

**\[Use Cases]**

```plaintext
sonic(config)# geoip load default
please config reload to make load effective
sonic(config)# reload
```

### <font color="#1d50a2">geosite lookup *string*</font>

**\[Command]**
**geosite lookup *string***

**\[Purpose]**
Based on domain, query the geosite and find the country code corresponding to the domain name according to the dat file.

**\[View]**
System configuration view

**\[Use Cases]**

```plaintext
sonic(config)# geosite lookup www.baidu.com
Matched country: BAIDU
Matched country: CN
Matched country: GEOLOCATION-CN
```

### <font color="#1d50a2">geoip lookup *string*</font>

**\[Command]**
**geoip lookup *string***

**\[Purpose]**
Based on IP, geoip can be queried, and the country code corresponding to the domain name can be found according to the dat file

**\[View]**
System configuration view

**\[Use Cases]**

```plaintext
sonic(config)# geoip lookup 52.62.62.62
IPv4 52.62.62.62 Matched country: AU
```

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

**\[Command]**
**rule *rule\_id* \[*\{packet-action \{deny|permit}}]  \[src-ip ip-address] \[dst-ip ip-address]\[src-port port] \[dst-port port] \[ip-type type]\[geosite string] \[geoip string*]**
**no rule *rule\_id***

**\[Purpose]**
Add geography/geip ACL rules

**\[Parameter]**

| **Parameter**       | **Description**                                                                                                |
| ------------------- | -------------------------------------------------------------------------------------------------------------- |
| *rule\_id*          | Rule ID. Range: 0-500. Also represents rule priority (higher number = higher priority). Values must be unique. |
| *packet-action*     | Packet action when a rule is matched.                                                                          |
| *deny*              | Drop.                                                                                                          |
| *permit*            | Allow to pass.                                                                                                 |
| *src-ip ip-address* | Source IP address. Format: A.B.C.D/M.                                                                          |
| *dst-ip ip-address* | Destination IP address. Format: A.B.C.D/M.                                                                     |
| *geosite string*    | Geosite matching field. `string` is the country code to match (e.g., BAIDU). Case-insensitive.                 |
| *geoip string*      | Geoip matching field. `string` is the country code to match (e.g., US). Case-insensitive.                      |

**\[View]**
ACL view

**\[Use Cases]**

```plaintext
sonic(config)# access-list L3 test ingress
sonic(config-L3-acl-test)# rule 1 geosite BAIDU packet-action permit
```

### <font color="#1d50a2">geosite *string*</font>

**\[Command]**
**geosite *string***

**\[Purpose]**
Add geosite matching rules

**\[Parameter]**

| **Parameter** | **Description**                                                                             |
| ------------- | ------------------------------------------------------------------------------------------- |
| *string*      | geosite matching field, fill in the country code that needs to be matched, case insensitive |

**\[View]**
Route policy view

**\[Notes]**
Policy-based Routing (PBR) maps cannot consist solely of geosite/geoip match fields; they must be used in combination with quintuple match conditions. For example, you can configure a full source IP match: match src-ip 0.0.0.0/0.

**\[Use Cases]**

```plaintext
sonic(config)# pbr-map test seq 5
sonic(config-pbr-map)# match src-ip 0.0.0.0/0
sonic(config-pbr-map)# geosite BAIDU
sonic(config-pbr-map)# set nexthop 192.168.2.1
```

### <font color="#1d50a2">geoip *string*</font>

**\[Command]**
**geoip *string***

**\[Purpose]**
Add geoip matching rules

**\[Parameter]**

| **Parameter** | **Description**                                                                           |
| ------------- | ----------------------------------------------------------------------------------------- |
| *string*      | geoip matching field, fill in the country code that needs to be matched, case insensitive |

**\[View]**
Route policy view

**\[Notes]**
Policy-based Routing (PBR) maps cannot consist solely of geosite/geoip match fields; they must be used in combination with quintuple match conditions. For example, you can configure a full source IP match: match src-ip 0.0.0.0/0.

**\[Use Cases]**

```plaintext
sonic(config)# pbr-map test seq 5
sonic(config-pbr-map)# match src-ip 0.0.0.0/0
sonic(config-pbr-map)# geoip CN
sonic(config-pbr-map)# set nexthop 192.168.2.1
```

