Skip to content

一、安装

  • 参考

https://www.maxmind.com/en/geoip2-databases

https://docs.nginx.com/nginx/admin-guide/dynamic-modules/geoip2/

https://www.fengbohello.top/archives/ip2location-geolite2

#!/bin/bash

yum install epel-release -y
yum install gcc unzip gcc-c++ git wget bind-utils make iptables-services -y

cd /usr/local/src
rm -rf *
mv /etc/localtime /etc/localtime.bak
/bin/cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'ZONE="CST"' > /etc/sysconfig/clock

setenforce 0
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config

systemctl disable firewalld
systemctl stop firewalld

chkconfig iptables on
service iptables start
iptables -F
service iptables save


cd /usr/local/src/
wget http://download.zhufunin.com/libmaxminddb-1.3.2.tar.gz
tar -zxf libmaxminddb-1.3.2.tar.gz
cd libmaxminddb-1.3.2
./configure
make && make install
[[ -z `cat /etc/ld.so.conf |grep "\/usr\/local\/lib"` ]] && echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig


mkdir -p /usr/local/nginx/temp
mkdir -p /usr/local/nginx/geoip
cd /usr/local/nginx/geoip

wget http://download.zhufunin.com/maxmind-city.mmdb.tar.gz
tar zxf maxmind-city.mmdb.tar.gz

cd /usr/local/src/
wget http://download.zhufunin.com/openssl-1.1.0e.tar.gz
tar zxf openssl-1.1.0e.tar.gz

wget http://download.zhufunin.com/pcre-8.42.tar.gz
tar zxf pcre-8.42.tar.gz


wget http://download.zhufunin.com/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz

wget http://download.zhufunin.com/ngx_http_geoip2_module.zip
unzip -o ngx_http_geoip2_module.zip

cd /usr/local/src

wget http://download.zhufunin.com/tengine-2.3.1.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_check_module.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_dynamic_module.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_keepalive_module.tar.gz


#nginx-1.22
wget -c https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/3.4.tar.gz -O /usr/local/src/ngx_http_geoip2_module-3.4.tar.gz

tar zxvf tengine-2.3.1.tar.gz
tar zxvf ngx_http_upstream_check_module.tar.gz
tar zxvf ngx_http_upstream_dynamic_module.tar.gz
tar zxvf ngx_http_upstream_keepalive_module.tar.gz

useradd -M -s /sbin/nologin www
cd /usr/local/src/tengine-2.3.1
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp \
--http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp \
--with-openssl=/usr/local/src/openssl-1.1.0e \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-pcre=/usr/local/src/pcre-8.42 \
--add-module=/usr/local/src/ngx_http_geoip2_module-master \
--add-module=/usr/local/src/ngx_http_upstream_dynamic_module \
--add-module=/usr/local/src/ngx_http_upstream_check_module

make && make install



echo "export PATH=$PATH:/usr/local/nginx/sbin/" >> /etc/profile
source /etc/profile

mkdir -p /usr/local/nginx/conf/autoconfig/vhost/
mkdir -p /usr/local/nginx/conf/autoconfig/upstream/
mkdir -p /usr/local/nginx/conf/autoconfig/cache/
mkdir -p /usr/local/nginx/conf/include/



mkdir -p /usr/local/shell/data

mkdir -p /usr/local/nginx/temp/proxy_store/client_body_temp

mkdir -p /usr/local/nginx/challenges

mkdir -p /usr/local/nginx/temp/proxy_store/

mkdir -p /usr/local/nginx/ssl

openssl req -x509 -nodes -days 10000 -newkey rsa:2048 -keyout /usr/local/nginx/nginx.key -out /usr/local/nginx/nginx.crt -subj "/C=US/ST=US/L=US/O=ssl/OU=ssl/CN=ssl.com/emailAddress=admin@ssl.com"



echo "ulimit -n 65535" >> /etc/profile
echo "root soft nofile 65535" >> /etc/security/limits.conf
echo "root hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
#!/bin/bash

yum install epel-release -y
yum install gcc unzip gcc-c++ git wget bind-utils make iptables-services -y

cd /usr/local/src
rm -rf *
mv /etc/localtime /etc/localtime.bak
/bin/cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'ZONE="CST"' > /etc/sysconfig/clock

setenforce 0
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config

systemctl disable firewalld
systemctl stop firewalld

chkconfig iptables on
service iptables start
iptables -F
service iptables save


cd /usr/local/src/
wget http://download.zhufunin.com/libmaxminddb-1.3.2.tar.gz
tar -zxf libmaxminddb-1.3.2.tar.gz
cd libmaxminddb-1.3.2
./configure
make && make install
[[ -z `cat /etc/ld.so.conf |grep "\/usr\/local\/lib"` ]] && echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig


mkdir -p /usr/local/nginx/temp
mkdir -p /usr/local/nginx/geoip
cd /usr/local/nginx/geoip

wget http://download.zhufunin.com/maxmind-city.mmdb.tar.gz
tar zxf maxmind-city.mmdb.tar.gz

cd /usr/local/src/
wget http://download.zhufunin.com/openssl-1.1.0e.tar.gz
tar zxf openssl-1.1.0e.tar.gz

wget http://download.zhufunin.com/pcre-8.42.tar.gz
tar zxf pcre-8.42.tar.gz


wget http://download.zhufunin.com/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz

wget http://download.zhufunin.com/ngx_http_geoip2_module.zip
unzip -o ngx_http_geoip2_module.zip

cd /usr/local/src

wget http://download.zhufunin.com/tengine-2.3.1.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_check_module.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_dynamic_module.tar.gz
wget http://download.zhufunin.com/ngx_http_upstream_keepalive_module.tar.gz


#nginx-1.22
wget -c https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/3.4.tar.gz -O /usr/local/src/ngx_http_geoip2_module-3.4.tar.gz

tar zxvf tengine-2.3.1.tar.gz
tar zxvf ngx_http_upstream_check_module.tar.gz
tar zxvf ngx_http_upstream_dynamic_module.tar.gz
tar zxvf ngx_http_upstream_keepalive_module.tar.gz

useradd -M -s /sbin/nologin www
cd /usr/local/src/tengine-2.3.1
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp \
--http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp \
--with-openssl=/usr/local/src/openssl-1.1.0e \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-pcre=/usr/local/src/pcre-8.42 \
--add-module=/usr/local/src/ngx_http_geoip2_module-master \
--add-module=/usr/local/src/ngx_http_upstream_dynamic_module \
--add-module=/usr/local/src/ngx_http_upstream_check_module

make && make install



echo "export PATH=$PATH:/usr/local/nginx/sbin/" >> /etc/profile
source /etc/profile

mkdir -p /usr/local/nginx/conf/autoconfig/vhost/
mkdir -p /usr/local/nginx/conf/autoconfig/upstream/
mkdir -p /usr/local/nginx/conf/autoconfig/cache/
mkdir -p /usr/local/nginx/conf/include/



mkdir -p /usr/local/shell/data

mkdir -p /usr/local/nginx/temp/proxy_store/client_body_temp

mkdir -p /usr/local/nginx/challenges

mkdir -p /usr/local/nginx/temp/proxy_store/

mkdir -p /usr/local/nginx/ssl

openssl req -x509 -nodes -days 10000 -newkey rsa:2048 -keyout /usr/local/nginx/nginx.key -out /usr/local/nginx/nginx.crt -subj "/C=US/ST=US/L=US/O=ssl/OU=ssl/CN=ssl.com/emailAddress=admin@ssl.com"



echo "ulimit -n 65535" >> /etc/profile
echo "root soft nofile 65535" >> /etc/security/limits.conf
echo "root hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf

二、配置

  • nginx 上配置
http {

geoip2 /data/apps/nginx/geoip/maxmind-city.mmdb {
    $geoip2_data_country_code default=CN source=$http_x_forwarded_for country iso_code;
    $geoip2_data_country_name country names en;
    $geoip2_data_city_name default=Beijing city names en;
   
    $geoip2_data_subdivisions_name default=Beijing subdivisions 0 names en;

    $geoip2_data_province_name subdivisions 0 names en;
    $geoip2_data_province_isocode subdivisions 0 iso_code;
}

log_format es '$server_addr`$host`$remote_addr`$http_x_forwarded_for`$time_local`$request_uri`$request_length`$bytes_sent`$request_time`$status`$upstream_addr`$upstream_cache_status`$upstream_response_time`$request_method`$http_user_agent`$upstream_status`$geoip2_data_city_name`$geoip2_data_subdivisions_name`$geoip2_data_country_name`$geoip2_data_country_code';

$geoip2_data_country_name:请求所属的国家
$geoip2_data_subdivisions_name:请求所属的省份或地区
$geoip2_data_city_name:请求所属的城市
}
http {

geoip2 /data/apps/nginx/geoip/maxmind-city.mmdb {
    $geoip2_data_country_code default=CN source=$http_x_forwarded_for country iso_code;
    $geoip2_data_country_name country names en;
    $geoip2_data_city_name default=Beijing city names en;
   
    $geoip2_data_subdivisions_name default=Beijing subdivisions 0 names en;

    $geoip2_data_province_name subdivisions 0 names en;
    $geoip2_data_province_isocode subdivisions 0 iso_code;
}

log_format es '$server_addr`$host`$remote_addr`$http_x_forwarded_for`$time_local`$request_uri`$request_length`$bytes_sent`$request_time`$status`$upstream_addr`$upstream_cache_status`$upstream_response_time`$request_method`$http_user_agent`$upstream_status`$geoip2_data_city_name`$geoip2_data_subdivisions_name`$geoip2_data_country_name`$geoip2_data_country_code';

$geoip2_data_country_name:请求所属的国家
$geoip2_data_subdivisions_name:请求所属的省份或地区
$geoip2_data_city_name:请求所属的城市
}
  • vhost
server {
    listen 80;
    server_name test.freehan.ink;

  add_header Geo-City "$geoip2_data_city_name";
  add_header Geo-Country "$geoip2_data_country_code";

    location / {
        index  index.html index.htm;
	rewrite /hello /go/index.html last;
    }

location /myip {
        default_type text/plain;
        return 200 "$remote_addr $geoip2_data_city_name $geoip2_data_country_name $geoip2_data_country_code";
    }
	access_log /var/log/nginx/cdn.log es;
}
server {
    listen 80;
    server_name test.freehan.ink;

  add_header Geo-City "$geoip2_data_city_name";
  add_header Geo-Country "$geoip2_data_country_code";

    location / {
        index  index.html index.htm;
	rewrite /hello /go/index.html last;
    }

location /myip {
        default_type text/plain;
        return 200 "$remote_addr $geoip2_data_city_name $geoip2_data_country_name $geoip2_data_country_code";
    }
	access_log /var/log/nginx/cdn.log es;
}
  • 效果
172.17.155.86`xxx.com`47.92.50.96`-`30/Dec/2019:16:41:56 +0800`/`185`0`0.000`200`-`-`-`GET`Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0`-`Shenzhen`China`CN
172.17.155.86`xxx.com`47.92.50.96`-`30/Dec/2019:16:41:56 +0800`/`185`0`0.000`200`-`-`-`GET`Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0`-`Shenzhen`China`CN
  • 定期更新geoip2
#!/bin/bash
cd /usr/local/nginx/geoip/
rm -rf /usr/local/nginx/geoip/GeoLite2-City_*
rm -rf /usr/local/nginx/geoip/GeoLite2-City.tar.gz*
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
code="$?"
echo $code
if test "$code" -ne 0 ;then
    echo "Download is failed"
    exit 0;
fi
tar zxf GeoLite2-City.tar.gz
cd GeoLite2-City_*
if test ! -e GeoLite2-City.mmdb; then
    exit 0;
fi
size=`du -s ./GeoLite2-City.mmdb |awk '{print $1}'`
if test "$size" -lt 50000;then
    exit 0;
fi
echo "mv GeoLite2-City.mmdb maxmind-city.mmdb"
mv GeoLite2-City.mmdb maxmind-city.mmdb
echo "mv maxmind-city.mmdb /usr/local/nginx/geoip/"
mv maxmind-city.mmdb /usr/local/nginx/geoip/
#!/bin/bash
cd /usr/local/nginx/geoip/
rm -rf /usr/local/nginx/geoip/GeoLite2-City_*
rm -rf /usr/local/nginx/geoip/GeoLite2-City.tar.gz*
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
code="$?"
echo $code
if test "$code" -ne 0 ;then
    echo "Download is failed"
    exit 0;
fi
tar zxf GeoLite2-City.tar.gz
cd GeoLite2-City_*
if test ! -e GeoLite2-City.mmdb; then
    exit 0;
fi
size=`du -s ./GeoLite2-City.mmdb |awk '{print $1}'`
if test "$size" -lt 50000;then
    exit 0;
fi
echo "mv GeoLite2-City.mmdb maxmind-city.mmdb"
mv GeoLite2-City.mmdb maxmind-city.mmdb
echo "mv maxmind-city.mmdb /usr/local/nginx/geoip/"
mv maxmind-city.mmdb /usr/local/nginx/geoip/
#免费库
hxopensource1990@gmail.com
ar3*hK9Tp9shu_N

https://www.maxmind.com/en/accounts/590775/geoip/downloads
#免费库
hxopensource1990@gmail.com
ar3*hK9Tp9shu_N

https://www.maxmind.com/en/accounts/590775/geoip/downloads
  • 另一种配置
bash

# 1.在 nginx.conf 中进行如下几个关键部分配置。
$ vim nginx.conf
worker_processes  auto;
# -- 关键点: 加载 geoip2 模块动态链接库
load_module modules/ngx_http_geoip2_module.so;
load_module modules/ngx_stream_geoip2_module.so;
....

http {
    ...
    # -- 关键点: 日志格式
    log_format demo '$remote_addr - [ $geoip2_country_code $geoip2_data_city_name ] - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for" rt=$request_time urt=$upstream_response_time';
    
   # -- 关键点: geoip 模块变量绑定
    geoip2 /usr/local/GeoIP2/GeoLite2-Country.mmdb {
      $geoip2_country_code country names en;
    }
    geoip2 /usr/local/GeoIP2/GeoLite2-City.mmdb {
      $geoip2_data_country_name country names en;
      $geoip2_data_country_code default=China source=$remote_addr country iso_code;
      $geoip2_data_city_name city names en;
      $geoip2_data_province_name subdivisions 0 names en;
      $geoip2_data_province_isocode subdivisions 0 iso_code;
      $geoip2_continent_code continent code;
    }
    ...
}

# 2.在 demo.conf 配置如下 location 以验证 GeoIP。
server {
....
  # -- 关键点: 访问日志设置
  access_log /var/log/nginx/demo-${logdate}.log demo;
  ...
  # -- 关键点: 该路径显示当前请求访问地址信息
  location = /api/v1/info {
     default_type text/plain;
     return 200 "$remote_addr\n geoip2_country_code=$geoip2_country_code\n geoip2_data_country_name=$geoip2_data_country_name \n geoip2_data_country_code=$geoip2_data_country_code \n geoip2_data_city_name=$geoip2_data_city_name \n geoip2_continent_code=$geoip2_continent_code \n geoip2_data_province_name=$geoip2_data_province_name \n geoip2_data_province_isocode=$geoip2_data_province_isocode";
   }
...
}

# 1.在 nginx.conf 中进行如下几个关键部分配置。
$ vim nginx.conf
worker_processes  auto;
# -- 关键点: 加载 geoip2 模块动态链接库
load_module modules/ngx_http_geoip2_module.so;
load_module modules/ngx_stream_geoip2_module.so;
....

http {
    ...
    # -- 关键点: 日志格式
    log_format demo '$remote_addr - [ $geoip2_country_code $geoip2_data_city_name ] - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for" rt=$request_time urt=$upstream_response_time';
    
   # -- 关键点: geoip 模块变量绑定
    geoip2 /usr/local/GeoIP2/GeoLite2-Country.mmdb {
      $geoip2_country_code country names en;
    }
    geoip2 /usr/local/GeoIP2/GeoLite2-City.mmdb {
      $geoip2_data_country_name country names en;
      $geoip2_data_country_code default=China source=$remote_addr country iso_code;
      $geoip2_data_city_name city names en;
      $geoip2_data_province_name subdivisions 0 names en;
      $geoip2_data_province_isocode subdivisions 0 iso_code;
      $geoip2_continent_code continent code;
    }
    ...
}

# 2.在 demo.conf 配置如下 location 以验证 GeoIP。
server {
....
  # -- 关键点: 访问日志设置
  access_log /var/log/nginx/demo-${logdate}.log demo;
  ...
  # -- 关键点: 该路径显示当前请求访问地址信息
  location = /api/v1/info {
     default_type text/plain;
     return 200 "$remote_addr\n geoip2_country_code=$geoip2_country_code\n geoip2_data_country_name=$geoip2_data_country_name \n geoip2_data_country_code=$geoip2_data_country_code \n geoip2_data_city_name=$geoip2_data_city_name \n geoip2_continent_code=$geoip2_continent_code \n geoip2_data_province_name=$geoip2_data_province_name \n geoip2_data_province_isocode=$geoip2_data_province_isocode";
   }
...
}

案例

http{
    ...
    
    geoip2 /usr/local/share/GeoIP/GeoLite2-Country.mmdb {
          $geoip2_country_code country iso_code;
    }
    
    map $geoip2_country_code $is_cn_country {
        default no;
        CN yes;
    }
    
    server {
        listen       80;
        server_name  localhost;
        #加上响应头方便调试
        add_header country $geoip2_country_code;
        
     
        location / {
        
            set $rootpath html/a;
            if ($is_jp_country = no) {
              set $rootpath html/b;
            }

            add_header rootpath $rootpath;
            add_header country $geoip2_country_code;
            root $rootpath;

            index index.html index.htm;
        
        }
    }
}
http{
    ...
    
    geoip2 /usr/local/share/GeoIP/GeoLite2-Country.mmdb {
          $geoip2_country_code country iso_code;
    }
    
    map $geoip2_country_code $is_cn_country {
        default no;
        CN yes;
    }
    
    server {
        listen       80;
        server_name  localhost;
        #加上响应头方便调试
        add_header country $geoip2_country_code;
        
     
        location / {
        
            set $rootpath html/a;
            if ($is_jp_country = no) {
              set $rootpath html/b;
            }

            add_header rootpath $rootpath;
            add_header country $geoip2_country_code;
            root $rootpath;

            index index.html index.htm;
        
        }
    }
}

非中国区域不能访问

geoip2 /data/apps/nginx/geoip/maxmind-city.mmdb {
    $geoip2_data_country_code default=CN source=$http_x_forwarded_for country iso_code;
    $geoip2_data_country_name country names en;
    $geoip2_data_city_name default=Shenzhen city names en;
    $geoip2_data_subdivisions_name default=Beijing subdivisions 0 names en;
    $geoip2_data_province_name subdivisions 0 names en;
    $geoip2_data_province_isocode subdivisions 0 iso_code;
}

log_format es '$server_addr`$host`$remote_addr`$http_x_forwarded_for`$time_local`$request_uri`$request_length`$bytes_sent`$request_time`$status`$upstream_addr`$upstream_cache_status`$upstream_response_time`$request_method`$http_user_agent`$upstream_status`$geoip2_data_city_name`$geoip2_data_subdivisions_name`$geoip2_data_country_name`$geoip2_data_country_code';


if ($geoip2_data_country_name != China){
    return 444;
}
if ($geoip2_data_country_code != CN) {
    return 444;
}
geoip2 /data/apps/nginx/geoip/maxmind-city.mmdb {
    $geoip2_data_country_code default=CN source=$http_x_forwarded_for country iso_code;
    $geoip2_data_country_name country names en;
    $geoip2_data_city_name default=Shenzhen city names en;
    $geoip2_data_subdivisions_name default=Beijing subdivisions 0 names en;
    $geoip2_data_province_name subdivisions 0 names en;
    $geoip2_data_province_isocode subdivisions 0 iso_code;
}

log_format es '$server_addr`$host`$remote_addr`$http_x_forwarded_for`$time_local`$request_uri`$request_length`$bytes_sent`$request_time`$status`$upstream_addr`$upstream_cache_status`$upstream_response_time`$request_method`$http_user_agent`$upstream_status`$geoip2_data_city_name`$geoip2_data_subdivisions_name`$geoip2_data_country_name`$geoip2_data_country_code';


if ($geoip2_data_country_name != China){
    return 444;
}
if ($geoip2_data_country_code != CN) {
    return 444;
}
if ($geoip2_data_subdivisions_name != Beijing){
    return 444;
}
if ($geoip2_data_country_name != China){
    return 444;
}
 if ($geoip2_data_country_code != CN) {
    return 444;
 }
if ($geoip2_data_subdivisions_name != Beijing){
    return 444;
}
if ($geoip2_data_country_name != China){
    return 444;
}
 if ($geoip2_data_country_code != CN) {
    return 444;
 }
  • 获取用户ip属于区域
bash
mmdblookup --file GeoLite2-City.mmdb --ip x.x.x.x

{
    "continent": 
      {
        "code": 
          "AS" <utf8_string>
        "geoname_id": 
          6255147 <uint32>
        "names": 
          {
            "de": 
              "Asien" <utf8_string>
            "en": 
              "Asia" <utf8_string>
            "es": 
              "Asia" <utf8_string>
            "fr": 
              "Asie" <utf8_string>
            "ja": 
              "アジア" <utf8_string>
            "pt-BR": 
              "Ásia" <utf8_string>
            "ru": 
              "Азия" <utf8_string>
            "zh-CN": 
              "亚洲" <utf8_string>
          }
      }
    "country": 
      {
        "geoname_id": 
          1562822 <uint32>
        "iso_code": 
          "VN" <utf8_string>
        "names": 
          {
            "de": 
              "Vietnam" <utf8_string>
            "en": 
              "Vietnam" <utf8_string>
            "es": 
              "Vietnam" <utf8_string>
            "fr": 
              "Vietnam" <utf8_string>
            "ja": 
              "ベトナム" <utf8_string>
            "pt-BR": 
              "Vietnã" <utf8_string>
            "ru": 
              "Вьетнам" <utf8_string>
            "zh-CN": 
              "越南" <utf8_string>
          }
      }
    "location": 
      {
        "accuracy_radius": 
          50 <uint16>
        "latitude": 
          16.002300 <double>
        "longitude": 
          105.999900 <double>
        "time_zone": 
          "Asia/Ho_Chi_Minh" <utf8_string>
      }
    "registered_country": 
      {
        "geoname_id": 
          1562822 <uint32>
        "iso_code": 
          "VN" <utf8_string>
        "names": 
          {
            "de": 
              "Vietnam" <utf8_string>
            "en": 
              "Vietnam" <utf8_string>
            "es": 
              "Vietnam" <utf8_string>
            "fr": 
              "Vietnam" <utf8_string>
            "ja": 
              "ベトナム" <utf8_string>
            "pt-BR": 
              "Vietnã" <utf8_string>
            "ru": 
              "Вьетнам" <utf8_string>
            "zh-CN": 
              "越南" <utf8_string>
          }
      }
  }
mmdblookup --file GeoLite2-City.mmdb --ip x.x.x.x

{
    "continent": 
      {
        "code": 
          "AS" <utf8_string>
        "geoname_id": 
          6255147 <uint32>
        "names": 
          {
            "de": 
              "Asien" <utf8_string>
            "en": 
              "Asia" <utf8_string>
            "es": 
              "Asia" <utf8_string>
            "fr": 
              "Asie" <utf8_string>
            "ja": 
              "アジア" <utf8_string>
            "pt-BR": 
              "Ásia" <utf8_string>
            "ru": 
              "Азия" <utf8_string>
            "zh-CN": 
              "亚洲" <utf8_string>
          }
      }
    "country": 
      {
        "geoname_id": 
          1562822 <uint32>
        "iso_code": 
          "VN" <utf8_string>
        "names": 
          {
            "de": 
              "Vietnam" <utf8_string>
            "en": 
              "Vietnam" <utf8_string>
            "es": 
              "Vietnam" <utf8_string>
            "fr": 
              "Vietnam" <utf8_string>
            "ja": 
              "ベトナム" <utf8_string>
            "pt-BR": 
              "Vietnã" <utf8_string>
            "ru": 
              "Вьетнам" <utf8_string>
            "zh-CN": 
              "越南" <utf8_string>
          }
      }
    "location": 
      {
        "accuracy_radius": 
          50 <uint16>
        "latitude": 
          16.002300 <double>
        "longitude": 
          105.999900 <double>
        "time_zone": 
          "Asia/Ho_Chi_Minh" <utf8_string>
      }
    "registered_country": 
      {
        "geoname_id": 
          1562822 <uint32>
        "iso_code": 
          "VN" <utf8_string>
        "names": 
          {
            "de": 
              "Vietnam" <utf8_string>
            "en": 
              "Vietnam" <utf8_string>
            "es": 
              "Vietnam" <utf8_string>
            "fr": 
              "Vietnam" <utf8_string>
            "ja": 
              "ベトナム" <utf8_string>
            "pt-BR": 
              "Vietnã" <utf8_string>
            "ru": 
              "Вьетнам" <utf8_string>
            "zh-CN": 
              "越南" <utf8_string>
          }
      }
  }