V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Tounea
V2EX  ›  程序员

各位大佬是怎么做来源 IP 做归属地分析的?

  •  
  •   Tounea · May 30, 2023 · 2184 views
    This topic created in 1067 days ago, the information mentioned may be changed or developed.
    我现在用的是 ELK Stack 版本 8.x.x ,使用 logstash

    filter {
    geoip {
    }
    }

    filter {
    ip2location {
    }
    }

    前者下载的 GeoLite2-City.mdb 文件,使用 geoiplookup -f GeoLite2-City.mdb 8.8.8.8 测试报错
    ```
    Error Traversing Database for ipnum = 1920103026 - Perhaps database is corrupt?
    Segmentation fault

    ```

    后者使用的是 BIN 二进制文件,使用 Logstash 发行来源 IP 归属地不准确,丝毫没有参考价值。

    请教下各位大佬有没有免费离线版本的 IP 库,能供程序调用的?
    6 replies    2023-05-31 15:50:27 +08:00
    fantastM
        1
    fantastM  
       May 30, 2023
    大多数开源项目里做 ip 所属地的判断,一般都是用 GeoLite2 (例如 clash 里 GEOIP 类型的规则),GeoLite2 是免费的,且每周二和周四更新两次数据,已经很不错了。需要更高精度的话,人家还提供了个商业版的 GeoIP2 。又想要免费 / 便宜,又想要好的服务,是不存在的

    https://dreamacro.github.io/clash/configuration/rules.html#geoip

    https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
    Tounea
        2
    Tounea  
    OP
       May 30, 2023
    @fantastM 我预期想要的就是能判断出 IP 的 国家和城市,奢望一点在加经纬度参数,不用高精度,差不多就行,能满足我这两个到三个需求足以!
    muzuiget
        3
    muzuiget  
       May 30, 2023
    是公网服务吗?如果套了个 Clouldflare 的话,Clouldflare 可以把这些数据通过 HTTP header 传给你,自己记录下来就好。
    Tounea
        4
    Tounea  
    OP
       May 30, 2023
    @muzuiget 不是公网服务,是在内网环境。
    thinkm
        5
    thinkm  
       May 30, 2023
    GeoLite2 国内一点都不准,国外准确的还可以
    JackCooper
        6
    JackCooper  
       May 31, 2023
    elk 数据进来之后 你的 index mapping 应该有 ip 这个字段, 直接使用 pipeline -> create pipeline -> geoIP

    默认走的是 GeoLite2-City.mmdb 定义好输入输入就可以直接用. 相对准
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2598 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 06:10 · PVG 14:10 · LAX 23:10 · JFK 02:10
    ♥ Do have faith in what you're doing.