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

做了个网站,每天定时更新 chnroutes 以及 curl 获取当前 IPv4 出口地址

  •  
  •   Showfom · 2015-05-14 13:22:12 +08:00 · 4321 次点击
    这是一个创建于 3297 天前的主题,其中的信息可能已经有所发展或是发生改变。

    下载地址

    http://ip.gs/chnroutes/

    这样就不用每次自己在电脑里执行了,本地下载 apnic 的资源实在是慢,服务器里快多了。

    因为 Linuxip-downMac 下的 ip-down 文件名冲突,所以我在文件名前面加入了前缀方便区别

    目前设置了每天北京时间 1314 分更新一次

    crontab 的内容,假设你的目录在 /var/www/chnroutes/

    14 13 * * * cd /var/www/chnroutes/ && /usr/bin/python /var/www/chnroutes/chnroutes.py -p mac
    14 13 * * * cd /var/www/chnroutes/ && /usr/bin/python /var/www/chnroutes/chnroutes.py -p linux
    14 13 * * * cd /var/www/chnroutes/ && /usr/bin/python /var/www/chnroutes/chnroutes.py -p win
    

    chnroutes 使用方法

    请参考

    https://github.com/fivesheep/chnroutes

    其他

    同时 ip.gs 还有一个很好的用法,在终端下输入 curl ip.gs 即可获取当前自己的外网出口 IPv4 地址

    感谢

    IP 数据库由 http://www.ipip.net/ 提供

    15 条回复    2015-05-18 10:00:05 +08:00
    Septembers
        1
    Septembers  
       2015-05-14 13:24:57 +08:00
    感谢 虽然我用不上
    winooxx
        2
    winooxx  
       2015-05-14 13:33:04 +08:00 via Android
    支持!
    694380889
        3
    694380889  
       2015-05-14 13:48:10 +08:00
    我使用 curl ip.gs 获取到的地址是错的
    fengzhihai2014
        4
    fengzhihai2014  
       2015-05-14 14:12:27 +08:00
    赞一个
    Delbert
        5
    Delbert  
       2015-05-14 14:57:27 +08:00
    curl ip.gs 和 curl ip.cn 得到的IP地址不同。
    Delbert
        6
    Delbert  
       2015-05-14 15:00:27 +08:00
    ip.gs 为 219.231.x.x 网段 山东省济南市 山东大学
    ip.cn 为 222.175.x.x 网段 山东省济南市 电信
    ip.tl 为 2001:da8:7000:6033:xxxx:xxxx:xxxx:xxxx
    Yien
        7
    Yien  
       2015-05-14 15:03:01 +08:00 via Android
    感谢分享
    Showfom
        8
    Showfom  
    OP
       2015-05-14 15:47:57 +08:00
    @Delbert 我擦。。。那你到底是什么出口
    aiguozhedaodan
        9
    aiguozhedaodan  
       2015-05-14 15:55:49 +08:00 via Android
    @Delbert
    @Showfom
    校园网至少有两个出口,教育网出口就会是效果1,电信出口就会是效果2,同理也能看到移动和联通的出口。至少我这里是这样。
    Delbert
        10
    Delbert  
       2015-05-14 17:02:45 +08:00
    @Showfom 电脑本机IP是第一个,ipconfig /all得到。
    @aiguozhedaodan 也就是说,走电信出口的话,实际上得不到我真正的IP地址?

    @Showfom 我宿舍和实验室还不一个网段,晚上回去看一下。
    Themyth
        11
    Themyth  
       2015-05-14 17:30:05 +08:00
    已经使用,感谢:)
    Showfom
        12
    Showfom  
    OP
       2015-05-15 01:01:31 +08:00
    @Delbert 说明我们的 IP 段在教育网访问的列表里?
    Delbert
        13
    Delbert  
       2015-05-15 07:51:12 +08:00
    @Showfom

    不是,只能说获取到了真实的本机ip。
    实际上页面访问ip.cn也是219,但是curl就不是……

    而且每个人的ip都是独立的公网ip(学校人好多的说。)
    mingyun
        14
    mingyun  
       2015-05-17 14:00:44 +08:00
    pH
        15
    pH  
       2015-05-18 10:00:05 +08:00
    @Delbert 类似这种校园网的IP,确实感觉是多种的。一直对这个比较烦。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1543 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 17:09 · PVG 01:09 · LAX 10:09 · JFK 13:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.