用Linux命令行获取本机外网IP地址
引言:目前获取ip的方法中,ifconfig和ip获取函数得到的都是内网ip。有时候需要获取外网ip,目前通用的做法,是向外部服务器发送请求,解析外部服务器响应,从而得到的自己的外网ip。linux下的 curl可以替我们完成这些工作,当然,不怕麻烦的话,可以自己分析http协议,自己实现以上过程。如果熟悉python的话,那就更简单了,就像我们所知道的,python总是有现成的库函数可供我们调用。一下总结几种获取外网ip的方法,以供查询,资料来源互联网。
$ curl ip.cn
$ curl ifconfig.me (目前已经失效)
$ curl ident.me 又可细分为 v4.ident.me 和 v6.ident.me
$ curl icanhazip.com
$ curl ipecho.net/plain
$ curl whatismyip.akamai.com
$ curl myip.dnsomatic.com
$ curl icanhazip.com
$ curl ip.3322.net
$ curl ip.6655.com/ip.aspx
如果需要返回IP和地区以及运营商的话可以使用:
$ curl cip.cc ------>纯IP的话 $ curl ip.cip.cc (http://www.cip.cc/) 推荐
$ curl ip.6655.com/ip.aspx?area=1
用Linux命令行获取本机外网IP地址的更多相关文章
- Linux命令行获取本机外网IP地址
问题: 服务器地址为net映射地址,本机ifconfig无法直接获取映射的公网地址. 方法: [root@TiaoBan- nidongde]# curl http://ifconfig.me 50. ...
- 【转】用Linux命令行获取本机外网IP地址
$ curl ifconfig.me $ curl icanhazip.com $ curl ident.me $ curl ipecho.net/plain $ curl whatismyip.ak ...
- 获取本机外网IP的工具类
ExternalIpAddressFetcher.java package com.tyust.common; import java.io.IOException; import java.io.I ...
- 获取本机外网ip和内网ip
获取本机外网ip //获取本机的公网IP public static string GetIP() { string tempip = ""; try { WebRequest r ...
- Linux 命令行获取天气
目标: 使用 Linux 命令行显示天气预报. 发行版: 所有 Linux 发行版. 要求: 能连上因特网的 Linux 难度: 容易 约定: # - 需要使用 root 权限来执行指定命令,可以直接 ...
- cURL 命令获取本机外网 IP
1.1 查询本机外网 IP # curl dhcp.cn 134.175.159.160 1.2 输出格式为 JSON # curl dhcp.cn/?json { "IP": & ...
- 查看本机外网ip地址
DOS下是无法查看外网IP的,只能获取本机内网IP地址 外网IP只能通过专门的测IP网站 http://www.ip138.com/ip2city.asp
- 获取本机外网ip
获取内网ip ifconfig eth0 | grep 'inet'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2}' 获取公网ip ifc ...
- 获取本机外网IP的方式笔记
1.IP138 网址:http://www.ip138.com/: 分离出的快速查询地址:http://20140507.ip138.com/ic.asp(2014年8月9日有效) 个人经验:百度搜索 ...
随机推荐
- 一个combineInputformat
mark import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import org.apa ...
- Fiddler 教程 转自小坦克
-- 此文章是转载小坦克的;直接复制文章的目的是因为原文章地址经常被重置,找不到原来的文章.小坦克博客园主页:https://home.cnblogs.com/u/TankXiao/ 目录 Fiddl ...
- win8 explorer 进程频繁奔溃的原因及处理
最近 , win8 系统中的 explorer 进程总是频繁奔溃 , 想想可能是最近新装或更新了什么软件引起的 . 查看了记录奔溃的详细信息 , 果不其然 , 是最近更新的快播新版本 ...
- ecshop二次开发添加快递
以天天快递为例:步骤1.打开includes\modules\shipping文件夹,把sto_express.php复制多一份,重名为tt_express.php:步骤2.打开tt_express. ...
- js原型对象,每个new出来的新对象都有独立的原型对象__proto__
刚才看一篇博文的时候, 动手测试了一下 JavaScript的原型链, 原型对象,发现每个构造器(赋给了某个 prototype ) new 出来的对象都有各自独立的原型对象 __proto__. p ...
- CodeForces 610B Vika and Squares
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...
- CodeForces 610A Pasha and Stick
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...
- CSS中的浮动清除
先来看一个实验:现在有两个div,div身上没有任何属性.每个div中都有li,这些li都是浮动的. 理想的效果:可实际的效果: 这个地方就涉及到浮动,因为两个父元素div都没有高度(或者小于子元素的 ...
- jquery.validate.js 一个jQuery验证格式控件
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- (中等) POJ 2528 Mayor's posters , 离散+线段树。
Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...