Skip to content
Ask AI

Geosite/Geoip Configuration Guide

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.

OperationCommandDescription
Enter the system configuration viewconfigure terminal
Load the geosite.dat filegeosite 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 filegeoip 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
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Query geosite based on domaingeosite lookup stringstring:Fill in the domain name to be queried, and all country codes corresponding to the domain name will be displayed
Query geoIP based on IPgeoip lookup A.B.C.DA.B.C.D:Fill* in the IP address that needs to be queried, and the country code corresponding to the IP will be displayed*
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Enter ACL configuration viewaccess-list {L3|L3V6} {ingress|egress}Enter ACL configuration view
Configure the geosite field that needs to be matchedgeosite String:The country code corresponding to the geosite that needs to be matched
Configure the geoIP field that needs to be matchedgeoip string:The country code corresponding to the geoIP that needs to be matched
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Create a policy route and enter the policy route viewpbr-map seq name:Specify policy name
nubmer:
Configure the geosite field that needs to be matchedgeosite 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 matchedgeoip string:The country code corresponding to the geoIP that needs to be matched
OperationCommand
Display the currently loaded geosite.dat informationshow geosite summary
Display the currently loaded geoip.dat informationshow geoip summary

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.

Procedure

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