V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
asmoker
V2EX  ›  程序员

搭了个获取 IP 的服务

  •  
  •   asmoker ·
    asmoker · 2020-08-04 12:38:50 +08:00 · 9191 次点击
    这是一个创建于 1353 天前的主题,其中的信息可能已经有所发展或是发生改变。

    之前一直使用 ip.cn 获取主机的出口 IP,后来不知道咋回事儿, curl ip.cn 就一直报错:error code: 1020

    所以闲着没事儿自己搭了一个,有需要的可以自取,访问地址:ip.threep.top

    curl 访问:

    $ curl ip.threep.top
    

    域名的话你可以理解为 3P 比较好记 🙊

    第 1 条附言  ·  2020-08-04 14:18:06 +08:00
    还有老哥用 ApacheBench 帮忙压测,真的费心了 😀
    59 条回复    2020-08-05 09:31:55 +08:00
    baiduyixia
        1
    baiduyixia  
       2020-08-04 12:42:13 +08:00
    watzds
        2
    watzds  
       2020-08-04 12:43:57 +08:00 via Android
    curl ifconfig. io
    Satelli
        3
    Satelli  
       2020-08-04 12:44:15 +08:00
    ip.cn 已经卖了。作者迁移到 ip.fm 了。
    hatebugs
        4
    hatebugs  
       2020-08-04 12:44:28 +08:00 via Android
    域名太难记 一般用 cip.cc
    asmoker
        5
    asmoker  
    OP
       2020-08-04 12:44:33 +08:00
    gxm44
        6
    gxm44  
       2020-08-04 12:45:43 +08:00   ❤️ 5
    curl ip.sb
    realpg
        7
    realpg  
       2020-08-04 12:48:46 +08:00
    一般我用 ip addr
    Jirajine
        8
    Jirajine  
       2020-08-04 12:54:22 +08:00 via Android
    somalia
        9
    somalia  
       2020-08-04 12:59:20 +08:00
    opengps
        10
    opengps  
       2020-08-04 13:03:16 +08:00   ❤️ 1
    这功能似乎 v2 的站长们人手一个
    asmoker
        11
    asmoker  
    OP
       2020-08-04 13:05:23 +08:00 via Android
    哈哈哈 这不闲得么
    ghostwwg
        12
    ghostwwg  
       2020-08-04 13:07:45 +08:00   ❤️ 2
    deorth
        13
    deorth  
       2020-08-04 13:10:01 +08:00
    我以前也有一个,直到站点被虚拟空间服务商关了
    asmoker
        14
    asmoker  
    OP
       2020-08-04 13:18:48 +08:00 via Android
    @baiduyixia 这个 curl 不好搞
    Foxkeh
        15
    Foxkeh  
       2020-08-04 13:28:02 +08:00
    openwrt 里看到的, checkip.dyndns.com
    Soar360
        16
    Soar360  
       2020-08-04 13:28:05 +08:00
    所以,看看这个?
    http://ip.coderbusy.com/
    mikeguan
        17
    mikeguan  
       2020-08-04 13:33:40 +08:00 via Android
    我都是 Nginx 直接返回 remote_ip
    yaoguaishou
        18
    yaoguaishou  
       2020-08-04 13:34:35 +08:00 via Android
    我一直用 https://phus.lu/ip
    asmoker
        19
    asmoker  
    OP
       2020-08-04 13:42:02 +08:00 via Android
    @mikeguan 我这个也是这么操作的 😂😂😂
    falcon05
        20
    falcon05  
       2020-08-04 13:44:08 +08:00 via iPhone
    CallMeReznov
        21
    CallMeReznov  
       2020-08-04 13:51:41 +08:00
    ip.sb 我一直用这个,还有各种 API,方便实用好记
    glp664186796
        22
    glp664186796  
       2020-08-04 13:55:05 +08:00
    我的电脑已经翻墙。访问 ip.threep.top 会显示深圳的 ip,访问 ip.fm 会显示香港的 ip,为什么还不一样?
    internelp
        23
    internelp  
       2020-08-04 13:55:16 +08:00
    curl ipaddr.host
    asmoker
        24
    asmoker  
    OP
       2020-08-04 14:01:01 +08:00
    还有老哥用 ApacheBench 帮忙压测,真的费心了 😀
    asmoker
        25
    asmoker  
    OP
       2020-08-04 14:13:23 +08:00
    koharu
        26
    koharu  
       2020-08-04 14:13:58 +08:00
    wangritian
        27
    wangritian  
       2020-08-04 14:18:11 +08:00
    搞 freeswitch 的时候弄过 stun 服务,专门获取外网 ip 的协议
    lasuar
        28
    lasuar  
       2020-08-04 14:24:21 +08:00
    这个帖子不错 收藏了
    sikeerwei
        29
    sikeerwei  
       2020-08-04 14:25:59 +08:00
    curl ip.sb
    matrix67
        30
    matrix67  
       2020-08-04 14:29:55 +08:00
    @wangritian #27 现在都用 ipd


    Usage:
    ipd [OPTIONS]

    Application Options:
    -f, --country-db=FILE Path to GeoIP country database
    -c, --city-db=FILE Path to GeoIP city database
    -l, --listen=ADDR Listening address (default: :8080)
    -r, --reverse-lookup Perform reverse hostname lookups
    -p, --port-lookup Enable port lookup
    -t, --template=FILE Path to template (default: index.html)
    -H, --trusted-header=NAME Header to trust for remote IP, if present (e.g. X-Real-IP)
    -L, --log-level=[debug|info|warn|error|fatal|panic] Log level to use (default: info)

    Help Options:
    -h, --help Show this help message
    moonfly
        31
    moonfly  
       2020-08-04 14:32:28 +08:00
    我也在自己的博客主机上用 PHP 写了一个查 IP 的 api,
    后来觉得域名太长了,curl 要敲好多字符,于是在 .bash_profile 中封装了一个 cip() 的函数,
    shell 下直接执行 cip 返回我当前上网的公网 IP,PTR 和归属地信息,
    执行 cip {IP} 返回指定 IP 的归属地,PTR 信息;
    timothyye
        32
    timothyye  
       2020-08-04 14:35:02 +08:00
    我也搭了一个
    curl https://myip.biturl.top
    96412hj
        33
    96412hj  
       2020-08-04 14:40:58 +08:00
    钓鱼?
    wfifi
        34
    wfifi  
       2020-08-04 14:48:03 +08:00
    curl 访问 ip.cn 时带上 user agent,-L 参数处理重定向,内容就出来了
    smileawei
        35
    smileawei  
       2020-08-04 14:48:04 +08:00
    nginx 一段配置就搞定了。
    location / {
    default_type text/plain;
    return 200 "$remote_addr\n" ;
    }

    搭配 GEO IP 库 更佳。
    JamesR
        36
    JamesR  
       2020-08-04 14:56:24 +08:00
    0x4C
        37
    0x4C  
       2020-08-04 15:17:27 +08:00
    curl ifconfig.me
    这个挺好记的
    wakzz
        38
    wakzz  
       2020-08-04 15:20:10 +08:00
    curl ip.sb
    aaa5838769
        39
    aaa5838769  
       2020-08-04 15:24:23 +08:00
    支持一下,我还以为能获取其他 IP 的详细信息了。
    asmoker
        40
    asmoker  
    OP
       2020-08-04 15:47:03 +08:00
    @aaa5838769 curl myip.ipip.net 这个不错
    wangritian
        41
    wangritian  
       2020-08-04 16:38:10 +08:00
    @matrix67 感谢告知,方便给一下安装文档吗?在百度和谷歌试着搜了一些关键词,没有找到这个命令
    baymax123456
        42
    baymax123456  
       2020-08-04 17:46:38 +08:00
    curl ip.sb
    thinkingbullet
        43
    thinkingbullet  
       2020-08-04 18:15:18 +08:00
    已收到到这个宝库中 http://www.91tool.net
    lxk11153
        44
    lxk11153  
       2020-08-04 18:17:07 +08:00
    为啥不整个 frps 服务
    asmoker
        45
    asmoker  
    OP
       2020-08-04 18:23:15 +08:00 via Android
    @lxk11153 啊?没 get 到
    lxk11153
        46
    lxk11153  
       2020-08-04 18:25:58 +08:00
    masker
        47
    masker  
       2020-08-04 19:55:15 +08:00
    相同的轮子重复造
    gamexg
        48
    gamexg  
       2020-08-04 21:10:10 +08:00 via Android
    alfawei
        49
    alfawei  
       2020-08-04 21:22:32 +08:00 via iPhone
    Junn
        50
    Junn  
       2020-08-04 21:22:44 +08:00 via iPhone
    我就想问问用这个主要干嘛?
    leavic
        51
    leavic  
       2020-08-04 23:32:32 +08:00
    这个帖子的标签应该是轮子啊
    JamesR
        52
    JamesR  
       2020-08-04 23:34:12 +08:00
    @Junn #50 自己家里搭建的服务器给自己发邮件上报 IP 用的。
    Huelse
        53
    Huelse  
       2020-08-04 23:51:09 +08:00
    supermoonie
        54
    supermoonie  
       2020-08-05 00:04:29 +08:00 via iPhone
    https://httpbin.org/ip

    更多 api 就把 ip 去掉
    Leon6868
        55
    Leon6868  
       2020-08-05 00:05:35 +08:00
    话说 SSR 全局代理为何不能改变 IP (浏览器访问)
    Coolkk
        56
    Coolkk  
       2020-08-05 00:22:49 +08:00
    速度挺快啊
    bipy
        57
    bipy  
       2020-08-05 00:36:15 +08:00
    dogfood
        58
    dogfood  
       2020-08-05 01:13:22 +08:00
    fiht
        59
    fiht  
       2020-08-05 09:31:55 +08:00
    无独有偶:
    ➜ ~ curl ip.fht.im
    Hi 103.x.x.x from: HK

    我的加了个 geo 信息
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1453 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:57 · PVG 07:57 · LAX 16:57 · JFK 19:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.