V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
missdeer
V2EX  ›  分享创造

因为嫌 ifconfig.me 太慢,所以花了大半天时间在京东云上部署了个类似的 http://ifconfig.jd-app.com

  •  1
     
  •   missdeer · 2014-08-15 09:44:54 +08:00 · 5461 次点击
    这是一个创建于 3548 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2014-08-15 15:30:43 +08:00
    我收罗过一些获取出口IP的方法,但哪有自己搞的心里爽啊!
    external_addr=$(dig +short myip.opendns.com @resolver1.opendns.com)
    external_addr=$(curl http://ifconfig.me 2> /dev/null )
    external_addr=$(curl ip.appspot.com)
    external_addr=$(curl icanhazip.com)
    external_addr=$(curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+")
    17 条回复    2014-08-16 03:31:24 +08:00
    hcymk2
        1
    hcymk2  
       2014-08-15 10:02:35 +08:00
    好像是直接用bee弄的吧。
    qiuai
        2
    qiuai  
       2014-08-15 11:01:45 +08:00
    确实不错.不过为啥不弄个顶级域名...
    missdeer
        3
    missdeer  
    OP
       2014-08-15 11:08:20 +08:00
    @hcymk2 是的。

    @qiuai 要备案,没心思陪他们玩。
    jamesxu
        4
    jamesxu  
       2014-08-15 11:24:34 +08:00
    binux
        5
    binux  
       2014-08-15 11:34:21 +08:00
    qiuai
        6
    qiuai  
       2014-08-15 12:17:37 +08:00
    @missdeer =.=...我倒是有香港的机器,但是没太明白你这个环境要怎么搭建.
    qq529633582
        7
    qq529633582  
       2014-08-15 12:52:39 +08:00
    hcymk2
        8
    hcymk2  
       2014-08-15 12:53:47 +08:00
    要golang 的环境.
    zhujinliang
        9
    zhujinliang  
       2014-08-15 14:02:27 +08:00
    我用openresty搭了一个自用,其实有nginx+echo模块就足够了
    missdeer
        10
    missdeer  
    OP
       2014-08-15 14:02:46 +08:00
    @jamesxu
    听说过,域名没记住- -

    @binux
    @qq529633582
    主要是需要在curl ifconfig.xxx时返回一个干净的IP地址或其他参数的值,这样可以方便地用在shell脚本里

    @qiuai
    编译好的放在https://code.jd.com/missdeerme/ifconfig ,整个clone下来直接运行./ifconfig应该就行了,默认绑定端口8080,或改环境变量VCAP_APP_PORT
    missdeer
        11
    missdeer  
    OP
       2014-08-15 14:03:54 +08:00
    @zhujinliang 那得自己有服务器- -
    archean
        12
    archean  
       2014-08-15 15:21:14 +08:00
    dig +short myip.opendns.com @208.67.222.222 @208.67.220.220
    与 curl ifconfig.me 同样效果.
    qiuai
        13
    qiuai  
       2014-08-15 15:33:34 +08:00
    @missdeer 是64位环境的程序?
    # ./ifconfig
    -bash: ./ifconfig: cannot execute binary file
    missdeer
        14
    missdeer  
    OP
       2014-08-15 15:54:34 +08:00
    @qiuai
    [tvu@localhost ifconfig]$ file ifconfig
    ifconfig: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
    qiuai
        15
    qiuai  
       2014-08-15 16:26:29 +08:00
    @missdeer 不知道...我用centos 32位跑.就提示
    -bash: ./ifconfig: cannot execute binary file
    missdeer
        16
    missdeer  
    OP
       2014-08-15 17:08:53 +08:00
    @qiuai 嗯,我那个确实是64位的可执行文件。有第三方服务自动编译的 http://beta.gobuild.io/repo?id=256 下载对应版本的试试。
    msg7086
        17
    msg7086  
       2014-08-16 03:31:24 +08:00
    难道不是nginx+add_header就能搞定的么……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   832 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:35 · PVG 03:35 · LAX 12:35 · JFK 15:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.