• 请不要在回答技术问题时复制粘贴 AI 生成的内容
asmoker
V2EX  ›  程序员

搭了个获取 IP 的服务

  •  
  •   asmoker · Aug 4, 2020 · 11424 views
    This topic created in 2283 days ago, the information mentioned may be changed or developed.

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

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

    curl 访问:

    $ curl ip.threep.top
    

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

    Supplement 1  ·  Aug 4, 2020
    还有老哥用 ApacheBench 帮忙压测,真的费心了 😀
    59 replies  •  2020-08-05 09:31:55 +08:00
    watzds
    watzds
    Aug 4, 2020 via Android
    2
    curl ifconfig. io
    bsfx2
    bsfx2
    Aug 4, 2020
    3
    ip.cn 已经卖了。作者迁移到 ip.fm 了。
    hatebugs
    hatebugs
    Aug 4, 2020 via Android
    4
    域名太难记 一般用 cip.cc
    asmoker
    asmoker
    OP
    Aug 4, 2020
    5
    gxm44
    gxm44
    Aug 4, 2020❤️5
    6
    curl ip.sb
    realpg
    realpg
    Aug 4, 2020
    7
    一般我用 ip addr
    Jirajine
    Jirajine
    Aug 4, 2020 via Android
    8
    somalia
    somalia
    Aug 4, 2020
    9
    opengps
    opengps
    Aug 4, 2020❤️1
    10
    这功能似乎 v2 的站长们人手一个
    asmoker
    asmoker
    OP
    Aug 4, 2020 via Android
    11
    哈哈哈 这不闲得么
    ghostwwg
    ghostwwg
    Aug 4, 2020❤️2
    12
    deorth
    deorth
    Aug 4, 2020
    13
    我以前也有一个,直到站点被虚拟空间服务商关了
    asmoker
    asmoker
    OP
    Aug 4, 2020 via Android
    14
    @baiduyixia 这个 curl 不好搞
    Foxkeh
    Foxkeh
    Aug 4, 2020
    15
    openwrt 里看到的, checkip.dyndns.com
    Soar360
    Soar360
    Aug 4, 2020
    16
    所以,看看这个?
    http://ip.coderbusy.com/
    mikeguan
    mikeguan
    Aug 4, 2020 via Android
    17
    我都是 Nginx 直接返回 remote_ip
    yaoguaishou
    yaoguaishou
    Aug 4, 2020 via Android
    18
    我一直用 https://phus.lu/ip
    asmoker
    asmoker
    OP
    Aug 4, 2020 via Android
    19
    @mikeguan 我这个也是这么操作的 😂😂😂
    GG668v26Fd55CP5W
    GG668v26Fd55CP5W
    Aug 4, 2020 via iPhone
    20
    CallMeReznov
    CallMeReznov
    Aug 4, 2020
    21
    ip.sb 我一直用这个,还有各种 API,方便实用好记
    glp664186796
    glp664186796
    Aug 4, 2020
    22
    我的电脑已经翻墙。访问 ip.threep.top 会显示深圳的 ip,访问 ip.fm 会显示香港的 ip,为什么还不一样?
    internelp
    internelp
    Aug 4, 2020
    23
    curl ipaddr.host
    asmoker
    asmoker
    OP
    Aug 4, 2020
    24
    还有老哥用 ApacheBench 帮忙压测,真的费心了 😀
    asmoker
    asmoker
    OP
    Aug 4, 2020
    25
    koharu
    koharu
    Aug 4, 2020
    26
    WaldenHorizon
    WaldenHorizon
    Aug 4, 2020
    27
    搞 freeswitch 的时候弄过 stun 服务,专门获取外网 ip 的协议
    freemoon
    freemoon
    Aug 4, 2020
    28
    这个帖子不错 收藏了
    sikeerwei
    sikeerwei
    Aug 4, 2020
    29
    curl ip.sb
    matrix67
    matrix67
    Aug 4, 2020
    30
    @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
    moonfly
    Aug 4, 2020
    31
    我也在自己的博客主机上用 PHP 写了一个查 IP 的 api,
    后来觉得域名太长了,curl 要敲好多字符,于是在 .bash_profile 中封装了一个 cip() 的函数,
    shell 下直接执行 cip 返回我当前上网的公网 IP,PTR 和归属地信息,
    执行 cip {IP} 返回指定 IP 的归属地,PTR 信息;
    timothyye
    timothyye
    Aug 4, 2020
    32
    我也搭了一个
    curl https://myip.biturl.top
    96412hj
    96412hj
    Aug 4, 2020
    33
    钓鱼?
    wfifi
    wfifi
    Aug 4, 2020
    34
    curl 访问 ip.cn 时带上 user agent,-L 参数处理重定向,内容就出来了
    smileawei
    smileawei
    Aug 4, 2020
    35
    nginx 一段配置就搞定了。
    location / {
    default_type text/plain;
    return 200 "$remote_addr\n" ;
    }

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

    更多 api 就把 ip 去掉
    Leon6868
    Leon6868
    Aug 5, 2020
    55
    话说 SSR 全局代理为何不能改变 IP (浏览器访问)
    Coolkk
    Coolkk
    Aug 5, 2020
    56
    速度挺快啊
    fiht
    fiht
    Aug 5, 2020
    59
    无独有偶:
    ➜ ~ curl ip.fht.im
    Hi 103.x.x.x from: HK

    我的加了个 geo 信息
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2995 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 108ms · UTC 11:44 · PVG 19:44 · LAX 03:44 · JFK 06:44
    ♥ Do have faith in what you're doing.