linux curl以及网络信息查看

涉及命令:curl, ifconfig, wget, convert, ip
          
           ifconfig:
                     主要用户查看、配置网络
           wget:
                     主要用于下载文件,支持断点继续下载
           ip:
                    主要用户查看、配置网络
           convert:
                    主要用于图片的转换、合并等操作
           curl:
                    利用URL语法在命令行方式下工作的文件传输工具;
                    设计目的是作为一种WEB开发语言,取得HTML、CSS等;
                    大有可为的一门技术。


-------------------------------------------------------------------------------------


查看主机对外网IP地址:
curl ifconfig.me

curl ifconfig.me/ip

 

查看远程主机:
curl ifconfig.me/host

 

查看用户代理:
curl ifconfig.me/ua


查看对外端口:
curl ifconfig.me/port

 

其他命令:
curl ifconfig.me/lang
curl ifconfig.me/keepalive
curl ifconfig.me/connection
curl ifconfig.me/encoding
curl ifconfig.me/mime
curl ifconfig.me/charset
curl ifconfig.me/via
curl ifconfig.me/forwarded

不用curl的情况下查看对外IP:
wget -qO- icanhazip.com


将网络信息存为图片:
ifconfig | convert label:@- ip.png


查看所有的MAC地址:
ip link show

 

还有一些复杂的命令,有空可以试一试:

 

推荐写法
1 curl "http://checkip.dyndns.org/" 2>/dev/null|awk '{print $6}'|cut -d '<' -f1
2 curl -s "http://checkip.dyndns.org/"|cut -f 6 -d" "|cut -f 1 -d"<"
3 w3m -dump http://submit.apnic.net/templates/yourip.html | grep -P -o '(\d+\.){3}\d+'
4 curl -s "http://checkip.dyndns.org/"| sed 's/.*Address: \([0-9\.]*\).*/\1/g'
5 curl -s "http://checkip.dyndns.org/"|cut -d "<" -f7|cut -c 26-
6 curl ifconfig.me          重点推荐这个,实在是好记
7 curl icanhazip.com

不推荐写法(因为ip长度是可变的)
8 curl "http://checkip.dyndns.org/" 2>/dev/null|while read line;do echo ${line:76:12};done
9 curl "http://checkip.dyndns.org/" 2>/dev/null|cut -c 77-88
10 curl -s "http://checkip.dyndns.org/"|cut -c 77-88

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值