# Management Geolocation

Traditionally, NetBird's management system has relied on Geolocation databases. In version 0.26.0, we introduced support for posture checks. From this version onwards, NetBird uses the GeoLite2 City database from [MaxMind](https://www.maxmind.com) to identify a peer's geographical location based on its IP address.

<Note>
Even though we distribute the databases, MaxMind retains ownership. Please refer to the [license agreement](https://www.maxmind.com/en/geolite2/eula) details on MaxMind's website for specifics.
</Note>

This guide outlines the steps to configure Management with the GeoLite2 database

## Downloading the databases

Upon NetBird Application startup, our management checks if the GeoLite2 databases exist in its data directory. If not present, the
databases will be downloaded from the following URLs:

- GeoLite2 City Database: [Download Link](https://pkgs.netbird.io/geolocation-dbs/GeoLite2-City/download?suffix=tar.gz)
- GeoLite2 City Database (SHA256): [Download Link](https://pkgs.netbird.io/geolocation-dbs/GeoLite2-City/download?suffix=tar.gz.sha256)
- GeoLite2 City CSV Database: [Download Link](https://pkgs.netbird.io/geolocation-dbs/GeoLite2-City-CSV/download?suffix=zip)
- GeoLite2 City CSV Database (SHA256): [Download Link](https://pkgs.netbird.io/geolocation-dbs/GeoLite2-City-CSV/download?suffix=zip.sha256)

After downloading, the management system prepares the databases for use. If the databases already exist, the system will load and utilize the existing ones.

## Updating the GeoLite2 Database

The GeoLite2 databases are updated twice a week to reflect changes in geolocation data. It's crucial to keep your
local GeoLite2 databases updated. You can achieve this manually through the script provided below.

Here are the steps to update the GeoLite2 databases:

### Step 1. Switch to the infrastructure files directory:
```bash
cd netbird/infrastructure_files/
```

### Step 2. Run the script to download the GeoLite2 databases:
```bash
./download-geolite2.sh
```
After successfully running the script, two database files (`geonames.db` and `GeoLite2-City.mmdb`) are created in the
`netbird/infrastructure_files/` directory.

### Step 3. The next step involves moving these files into our management service container.

Move the `geonames.db` database:
```bash
docker-compose cp geonames.db management:/var/lib/netbird/
```

Move the `GeoLite2-City.mmdb` database:
```bash
docker-compose cp GeoLite2-City.mmdb management:/var/lib/netbird/
```

4. To complete the process,  restart the management service to ensure that it loads the updated databases:

```bash
docker-compose restart management
```
This completes the upgrade process. Your GeoLite2 databases are now up-to-date.
By following the guide above, your GeoLite2 databases should always be updated with the latest geolocation data.