Geosite/Geoip Configuration
show geosite summary
Section titled “show geosite summary”[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]
sonic# show geosite summaryGeosite Statistics: Use default geosite data Total Country Codes: 1403 Total Domain Rules : 108358show geoip summary
Section titled “show geoip summary”[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]
sonic# show geoip summaryGeoip Statistics: Use default geoip data Total Country Codes: 260 Total IPv4 counts: 627125 Total IPv6 counts: 655079geosite load
Section titled “geosite load”[Command] geosite loadstring|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]
sonic(config)# geosite load defaultplease config reload to make load effectivesonic(config)# reloadgeoip load
Section titled “geoip load”[Command] geoip loadstring|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]
sonic(config)# geoip load defaultplease config reload to make load effectivesonic(config)# reloadgeosite lookup
Section titled “geosite lookup”[Command] geosite lookupstring
[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]
sonic(config)# geosite lookup www.baidu.comMatched country: BAIDUMatched country: CNMatched country: GEOLOCATION-CNgeoip lookup
Section titled “geoip lookup”[Command] geoip lookupstring
[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]
sonic(config)# geoip lookup 52.62.62.62IPv4 52.62.62.62 Matched country: AU[Command] rulerule_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 rulerule_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]
sonic(config)# access-list L3 test ingresssonic(config-L3-acl-test)# rule 1 geosite BAIDU packet-action permitgeosite
Section titled “geosite”[Command] geositestring
[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]
sonic(config)# pbr-map test seq 5sonic(config-pbr-map)# match src-ip 0.0.0.0/0sonic(config-pbr-map)# geosite BAIDUsonic(config-pbr-map)# set nexthop 192.168.2.1[Command] geoipstring
[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]
sonic(config)# pbr-map test seq 5sonic(config-pbr-map)# match src-ip 0.0.0.0/0sonic(config-pbr-map)# geoip CNsonic(config-pbr-map)# set nexthop 192.168.2.1