linux下测试web访问及网络相关的命令

简介:

curl命令

curl是linux系统命令行下用来简单测试web访问的工具。

curl -xip:port www.baidu.com    -x可以指定ip和端口,省略写hosts,方便实用

-I    只显示状态码

-v    显示详细过程,可视化操作;

-u    指定用户名和密码

-O    下载网页文件

-o    自定义下载文件名

1
2
3
4
5
6
7
8
9
10
11
[root@localhost ~] # curl -x61.135.157.156:80 www.qq.com -I
HTTP /1 .1 200 OK
Server: squid /3 .4.1
Date: Mon, 20 Apr 2015 13:57:51 GMT
Content-Type: text /html ; charset=GB2312
Connection: keep-alive
Vary: Accept-Encoding
Expires: Mon, 20 Apr 2015 13:58:51 GMT
Cache-Control: max-age=60
Vary: Accept-Encoding
X-Cache: HIT from tianjin.qq.com

HTTP 200 代表网页正常。


curl -Iv www.qq.com    -I可以把访问的内容略掉,只显示状态码,-v可以显示详细过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@yong ~] # curl -Iv www.qq.com
* About to connect() to www.qq.com port 80 ( #0)
*   Trying 180.96.86.192... connected
* Connected to www.qq.com (180.96.86.192) port 80 ( #0)
> HEAD / HTTP /1 .1
> User-Agent: curl /7 .19.7 (i386-redhat-linux-gnu) libcurl /7 .19.7 NSS /3 .16.2.3 Basic ECC zlib /1 .2.3 libidn /1 .18 libssh2 /1 .4.2
> Host: www.qq.com
> Accept: */*
< HTTP /1 .1 200 OK
HTTP /1 .1 200 OK
< Server: squid /3 .4.1
Server: squid /3 .4.1
< Date: Fri, 24 Apr 2015 01:38:47 GMT
Date: Fri, 24 Apr 2015 01:38:47 GMT
< Content-Type: text /html ; charset=GB2312
Content-Type: text /html ; charset=GB2312
< Connection: keep-alive
Connection: keep-alive
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Expires: Fri, 24 Apr 2015 01:39:47 GMT
Expires: Fri, 24 Apr 2015 01:39:47 GMT
< Cache-Control: max-age=60
Cache-Control: max-age=60
< Vary: Accept-Encoding
Vary: Accept-Encoding
< X-Cache: HIT from nanjing.qq.com
X-Cache: HIT from nanjing.qq.com
* Connection  #0 to host www.qq.com left intact
* Closing connection  #0


curl -u user:password www.hao123.com    -u可以指定用户名和密码


使用-O 下载web网页;

示例,下载51cto博客网页,下载下来的文件是HTML文档;

1
2
3
4
5
6
7
8
[root@yong ~] # curl http://8802265.blog.51cto.com/8792265/1636847 -O
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
100 68527    0 68527    0     0   176k      0 --:--:-- --:--:-- --:--:--  224k
[root@yong ~] # file 1636847 
1636847: ISO-8859 HTML document text, with very long lines
[root@yong ~] # ls -l
-rw-r--r--  1 root root   68527 Apr 24 09:38 1636847


还可以使用 -o 自定义下载的名字

1
2
3
4
5
6
[root@yong ~] # curl http://8802265.blog.51cto.com/8792265/1636847 -o blog.html
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
100 68527    0 68527    0     0  87925      0 --:--:-- --:--:-- --:--:--   98k
[root@yong ~] # ls -l blog.html 
-rw-r--r-- 1 root root 68527 Apr 24 09:43 blog.html



linux下网络相关的几个命令

ping    测试网络是否通

格式:ping www.baidu.com -c 3    -c参数指定ping的次数

1
2
3
4
5
6
7
8
[root@yong ~] # ping www.baidu.com -c 3
PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.
64 bytes from 180.97.33.108: icmp_seq=1 ttl=53  time =32.6 ms
64 bytes from 180.97.33.108: icmp_seq=2 ttl=53  time =28.5 ms
64 bytes from 180.97.33.108: icmp_seq=3 ttl=53  time =29.2 ms
--- www.a.shifen.com  ping  statistics ---
3 packets transmitted, 3 received, 0% packet loss,  time  2034ms
rtt min /avg/max/mdev  = 28.558 /30 .130 /32 .623 /1 .788 ms


telnet    测试端口是否打开

安装telnet命令:yum install -y telnet

示例,访问百度的80端口可以连接,3389端口是关闭的;

1
2
3
4
[root@yong ~] # telnet www.qq.com 80
Trying 180.96.86.192...
Connected to www.qq.com
Escape character is  '^]' .
1
2
3
4
5
[root@yong ~] # telnet www.qq.com 3389
Trying 180.96.86.192...
telnet: connect to address 180.96.86.192: Connection timed out
Trying 240e:e1:8100:28::2:16...
telnet: connect to address 240e:e1:8100:28::2:16: Network is unreachable


traceroute    追踪路由表

安装traceroute命令: yum install -y traceroute

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@yong ~] # traceroute www.qq.com
traceroute  to www.qq.com (180.96.86.192), 30 hops max, 60 byte packets
  1  192.168.20.1 (192.168.20.1)  1.397 ms * *
  2  192.168.4.1 (192.168.4.1)  2.950 ms  2.415 ms  2.930 ms
  3  113.116.76.1 (113.116.76.1)  5.948 ms  5.539 ms  5.138 ms
  4  113.106.43.101 (113.106.43.101)  3.044 ms  3.567 ms  3.901 ms
  5  219.133.30.238 (219.133.30.238)  3.454 ms  3.070 ms  2.654 ms
  6  183.56.65.86 (183.56.65.86)  6.279 ms  5.681 ms 183.56.66.2 (183.56.66.2)  4.197 ms
  7  202.97.48.109 (202.97.48.109)  26.995 ms  26.693 ms  27.072 ms
  8  61.160.134.26 (61.160.134.26)  442.708 ms  442.285 ms  440.784 ms
  9  202.102.69.206 (202.102.69.206)  24.608 ms 202.102.69.202 (202.102.69.202)  28.271 ms 202.102.73.14 (202.102.73.14)  30.530 ms
10  180.96.48.6 (180.96.48.6)  23.971 ms 180.96.51.102 (180.96.51.102)  27.870 ms  27.521 ms
11  180.96.35.182 (180.96.35.182)  25.203 ms 180.96.48.206 (180.96.48.206)  23.814 ms 180.96.35.182 (180.96.35.182)  25.058 ms
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *



dig全称Domain Information Groper 域名信息搜索器,用于询问DNS的灵活的工具,显示从受请求的域名服务器返回的答复。和windows里面的nslookup一样的功能。

安装dig命令:yum install -y bind-utils

使用方法: dig @域名服务器 www.baidu.com

spacer.gif[root@yong ~]# dig @114.114.114.114 www.qq.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.2 <<>> @114.114.114.114 www.qq.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR,  id : 9644
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.qq.com.INA
;; ANSWER SECTION:
www.qq.com.181INA14.17.42.40
www.qq.com.181INA59.37.96.63
www.qq.com.181INA14.17.32.211
;; Query  time : 46 msec
;; SERVER: 114.114.114.114 #53(114.114.114.114)
;; WHEN: Fri Apr 24 09:53:01 2015
;; MSG SIZE  rcvd: 76


nc (netcat)功能强大的网络工具,扫描端口;

安装nc的命令:yum install -y nc

格式:nc -z -w2  -v www.baidu.com 1-1024  

-w2 表示2s超时;port 可以只写一个端口,也可以写一个范围。使用nc扫描端口时,必须要加 -z(将输入输出关闭)否则不显示结果。-v 显示详细信息,会把不开放的端口也显示出来;

1
2
3
4
5
6
7
8
[root@yong ~] # nc -z -w2 www.baidu.com 80
Connection to www.baidu.com 80 port [tcp /http ] succeeded!
[root@yong ~] # nc -z -v -w2 www.baidu.com 20-22
nc: connect to www.baidu.com port 20 (tcp) timed out: Operation now  in  progress
nc: connect to www.baidu.com port 20 (tcp) timed out: Operation now  in  progress
Connection to www.baidu.com 21 port [tcp /ftp ] succeeded!
nc: connect to www.baidu.com port 22 (tcp) timed out: Operation now  in  progress
nc: connect to www.baidu.com port 22 (tcp) timed out: Operation now  in  progress







本文转自 模范生 51CTO博客,原文链接:http://blog.51cto.com/mofansheng/1637821,如需转载请自行联系原作者

目录
相关文章
|
15天前
|
安全 Linux PHP
Web渗透-命令执行漏洞-及常见靶场检测实战
命令执行漏洞(RCE)指应用程序调用系统命令时,用户可控制输入参数,导致恶意命令被拼接执行,从而危害系统安全。常见于PHP的system、exec等函数。攻击者可通过命令连接符在目标系统上执行任意命令,造成数据泄露或服务瘫痪。漏洞成因包括代码层过滤不严、第三方组件缺陷等。可通过参数过滤、最小权限运行等方式防御。本文还介绍了绕过方式、靶场测试及复现过程。
212 0
|
6月前
|
测试技术
Fast网络速度测试工具
Fast是由Netflix提供的网络速度测试工具,可快速测量用户的下载、上传速度及延迟。其全球可用、无广告干扰,并支持多种设备。测试自动进行,结果以Mbps显示。此外,用户可通过“Show more info”查看上传速度和延迟(含缓冲膨胀)。Fast以其简单快捷的特点,帮助用户了解网络性能并解决潜在问题,是评估网速的理想选择。
425 0
Fast网络速度测试工具
|
4月前
|
移动开发 前端开发 JavaScript
前端web创建命令
本项目使用 Vite 搭建 Vue + TypeScript 开发环境,并基于 HTML5 Boilerplate 提供基础模板,快速启动现代前端开发。
46 2
|
5月前
|
人工智能 安全 程序员
用 Colab 和 ngrok 免费部署你的 Web UI 项目,随时随地访问!
用 Colab 和 ngrok 免费部署你的 Web UI 项目,随时随地访问!
|
9月前
|
Web App开发 编解码 vr&ar
使用Web浏览器访问UE应用的最佳实践
在3D/XR应用开发中,尤其是基于UE(虚幻引擎)开发的高精度场景,传统终端因硬件局限难以流畅运行高帧率、复杂效果的三维应用。实时云渲染技术,将渲染任务转移至云端服务器,降低终端硬件要求,确保用户获得流畅体验。具备弹性扩展、优化传输协议、跨平台支持和安全性等优势,适用于多种终端和场景,特别集成像素流送技术,帮助UE开发者实现低代码上云操作,简化部署流程,保留UE引擎的强大开发能力,确保画面精美且终端轻量化。
362 17
使用Web浏览器访问UE应用的最佳实践
|
11月前
|
数据库连接 Go 数据库
Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性
本文探讨了Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性;防御编程则强调在编码时考虑各种错误情况,确保程序健壮性。文章详细介绍了这两种技术在Go语言中的实现方法及其重要性,旨在提升软件质量和可靠性。
167 1
|
11月前
|
机器学习/深度学习 自然语言处理 前端开发
前端神经网络入门:Brain.js - 详细介绍和对比不同的实现 - CNN、RNN、DNN、FFNN -无需准备环境打开浏览器即可测试运行-支持WebGPU加速
本文介绍了如何使用 JavaScript 神经网络库 **Brain.js** 实现不同类型的神经网络,包括前馈神经网络(FFNN)、深度神经网络(DNN)和循环神经网络(RNN)。通过简单的示例和代码,帮助前端开发者快速入门并理解神经网络的基本概念。文章还对比了各类神经网络的特点和适用场景,并简要介绍了卷积神经网络(CNN)的替代方案。
1387 1
|
11月前
【Azure App Service】PowerShell脚本批量添加IP地址到Web App允许访问IP列表中
Web App取消公网访问后,只允许特定IP能访问Web App。需要写一下段PowerShell脚本,批量添加IP到Web App的允许访问IP列表里!
153 2
|
11月前
|
编解码 安全 Linux
网络空间安全之一个WH的超前沿全栈技术深入学习之路(10-2):保姆级别教会你如何搭建白帽黑客渗透测试系统环境Kali——Liinux-Debian:就怕你学成黑客啦!)作者——LJS
保姆级别教会你如何搭建白帽黑客渗透测试系统环境Kali以及常见的报错及对应解决方案、常用Kali功能简便化以及详解如何具体实现
|
11月前
|
人工智能 安全 Linux
网络空间安全之一个WH的超前沿全栈技术深入学习之路(4-2):渗透测试行业术语扫盲完结:就怕你学成黑客啦!)作者——LJS
网络空间安全之一个WH的超前沿全栈技术深入学习之路(4-2):渗透测试行业术语扫盲完结:就怕你学成黑客啦!)作者——LJS

热门文章

最新文章