onlytiancai / AIWebGuard

史上最强 AI web 防火墙
MIT License
2 stars 0 forks source link

IP 库讨论 #2

Open onlytiancai opened 3 months ago

onlytiancai commented 3 months ago

免费 IP 库:https://dev.maxmind.com/geoip/geolite2-free-geolocation-data 使用:

head /var/log/nginx/access.log | awk '{print $1}'|xargs -I {} ./mmdbinspect -db ./GeoLite2-City_20240329/GeoLite2-City.mmdb {} | jq -r '.[].Lookup + ", " +  .[].Records[].Record.country.iso_code'
45.79.181.94, US
192.155.88.231, US
114.119.157.156, SG
185.191.126.213, SC
134.122.61.39, NL
114.119.138.32, SG
180.188.25.233, CN
205.210.31.210, US
45.79.172.21, US
95.214.53.103, PL

参考:https://github.com/maxmind/mmdbinspect?tab=readme-ov-file#examples

onlytiancai commented 3 months ago

统计 Nginx 日志中请求量最大的 10 个国家

cat /var/log/nginx/access.log | awk '{print $1}'|xargs -I {} ./mmdbinspect -db ./GeoLite2-City_20240329/GeoLite2-City.mmdb {} | jq -r '.[].Records[].Record.country.iso_code' | sort | uniq -c | sort -rn | head
   1846 DE
     95 CN
     81 US
     53 RU
     51 SG
     42 IE
     35 NL
     14 BG
      7 RO
      6 PL