Skip to content

6.2 Geo Location Information

Gurdeep Singh (Guru) edited this page Aug 11, 2024 · 1 revision

Geo location

I have added a geo location tool that you can use in order to find, country, state or city information. To write ip2location filters, you need these information to get a match on the filter. This database is taking from github.com/dr5hn/ and there are some differences between dr5hn and ip2location database. So you might have to play around a bit with city name or state name. But its a good reference you can have handy.

To download the latest database from dr5hn git hub repository

admin@phpterminal:firewall(config)# get latest geodata 
...
OPTIONS: [Y | N]

GET LATEST VERSION OF GEODATA : Y

Downloading file ... (36775231/36775231)  100% [=============================================] 0:06 / 0:07

Processing download, this will take sometime...

Updated Geodata database.

admin@phpterminal:firewall(config)#

Once downloaded and installed, you can query the name of the country, state or city

admin@phpterminal:firewall# show geo countries | grep United

SHOW GEO COUNTRIES OUTPUT
+------------+----------------------+------------------------------------------------------------------------------------------------------+
| ID         | COUNTRY_CODE         | NAME                                                                                                 |
+------------+----------------------+------------------------------------------------------------------------------------------------------+
| 234        | UM                   | United States Minor Outlying Islands                                                                 |
| 231        | AE                   | United Arab Emirates                                                                                 |
| 232        | GB                   | United Kingdom                                                                                       |
| 233        | US                   | United States                                                                                        |
+------------+----------------------+------------------------------------------------------------------------------------------------------+

admin@phpterminal:firewall# show geo states us | grep cali


SHOW GEO STATES US OUTPUT
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+
| ID         | STATE_CODE           | COUNTRY_CODE         | NAME                                                                                                 |
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+
| 1416       | CA                   | US                   | California                                                                                           |
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+

admin@phpterminal:firewall# show geo cities us ca | grep franci


SHOW GEO CITIES US CA OUTPUT
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+
| ID         | STATE_CODE           | COUNTRY_CODE         | NAME                                                                                                 |
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+
| 126723     | CA                   | US                   | South San Francisco                                                                                  |
| 114046     | CA                   | US                   | City and County of San Francisco                                                                     |
| 125809     | CA                   | US                   | San Francisco                                                                                        |
+------------+----------------------+----------------------+------------------------------------------------------------------------------------------------------+

admin@phpterminal:firewall#