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 -IHTTP/1.1 200 OKServer: squid/3.4.1Date: Mon, 20 Apr 2015 13:57:51 GMTContent-Type: text/html; charset=GB2312Connection: keep-aliveVary: Accept-EncodingExpires: Mon, 20 Apr 2015 13:58:51 GMTCache-Control: max-age=60Vary: Accept-EncodingX-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 OKHTTP/1.1 200 OK< Server: squid/3.4.1Server: squid/3.4.1< Date: Fri, 24 Apr 2015 01:38:47 GMTDate: Fri, 24 Apr 2015 01:38:47 GMT< Content-Type: text/html; charset=GB2312Content-Type: text/html; charset=GB2312< Connection: keep-aliveConnection: keep-alive< Vary: Accept-EncodingVary: Accept-Encoding< Expires: Fri, 24 Apr 2015 01:39:47 GMTExpires: Fri, 24 Apr 2015 01:39:47 GMT< Cache-Control: max-age=60Cache-Control: max-age=60< Vary: Accept-EncodingVary: Accept-Encoding< X-Cache: HIT from nanjing.qq.comX-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 Speed100 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 Speed100 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 3PING 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 ms64 bytes from 180.97.33.108: icmp_seq=2 ttl=53 time=28.5 ms64 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 2034msrtt 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 80Trying 180.96.86.192...Connected to www.qq.comEscape character is '^]'. |
|
1
2
3
4
5
|
[root@yong ~]# telnet www.qq.com 3389Trying 180.96.86.192...telnet: connect to address 180.96.86.192: Connection timed outTrying 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.comtraceroute 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 ms10 180.96.48.6 (180.96.48.6) 23.971 ms 180.96.51.102 (180.96.51.102) 27.870 ms 27.521 ms11 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 ms12 * * *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
[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.40www.qq.com.181INA59.37.96.63www.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 80Connection to www.baidu.com 80 port [tcp/http] succeeded![root@yong ~]# nc -z -v -w2 www.baidu.com 20-22nc: connect to www.baidu.com port 20 (tcp) timed out: Operation now in progressnc: connect to www.baidu.com port 20 (tcp) timed out: Operation now in progressConnection to www.baidu.com 21 port [tcp/ftp] succeeded!nc: connect to www.baidu.com port 22 (tcp) timed out: Operation now in progressnc: connect to www.baidu.com port 22 (tcp) timed out: Operation now in progress |
linux下测试web访问及网络相关的命令的更多相关文章
- Linux下使用FreeTDS访问MS SQL Server 2005数据库(包含C测试源码)
Linux下使用FreeTDS访问MS SQL Server 2005数据库(包含C测试源码) http://blog.csdn.net/helonsy/article/details/7207497 ...
- 推荐一个linux下的web压力测试工具神器webbench
推荐一个linux下的web压力测试工具神器webbench2014-04-30 09:35:29 来源: 评论:0 点击:880 用多了apache的ab工具之后你就会发现ab存在很多问题, ...
- Linux系统下LNMP一键搭建Linux、PHP、MySQL环境(适合新手搭建linux下的web生成环境)
一. 首先要解释一下,什么是LNMP,LNMP起源于LAMP,LAMP是Linux+Apache+Mysql/MariaDB+Perl/PHP/Python的缩写,这里将Web服务端的Apache替换 ...
- Linux系统之网络相关的命令
Linux系统之网络相关的命令 网络概述 网络:通过通信介质和通信设备 将分布不同地点的两台或多台计算机,经过相应的程序实现通信switch 交换机router 路由器网络的功能:数据通信:利用网络传 ...
- linux 下部署web 程序
linux 下部署web 程序 1. 创建ucenter用户 一般情况下,发布应用程序都不是使用root用户的,需要创建一个普通用户来发布程序: 创建ucenter用户: useradd -d /uc ...
- linux下关于压缩、解压相关的操作
本文转自: http://alex09.iteye.com/blog/647128 很不错的linux下关于压缩.解压相关的操作,适合于linux初学者. .tar 解包:tar xvf Fil ...
- LINUX开启允许对外访问的网络端口
LINUX开启允许对外访问的网络端口 LINUX通过下面的命令可以开启允许对外访问的网络端口: /sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCE ...
- Linux下查看Web服务器当前的并发连接数和TCP连接状态
对于web服务器(Nginx.Apache等)来说,并发连接数是一个比较重要的参数,下面就通过netstat命令和awk来查看web服务器的并发连接数以及TCP连接状态. $ netstat -n | ...
- linux下测试磁盘的读写IO速度-简易方法
linux下测试磁盘的读写IO速度-简易方法 参考资料:https://blog.csdn.net/zqtsx/article/details/25487185 一:使用hdparm命令 这是一个是用 ...
随机推荐
- 数据解析框架之FastJson
演示实体类 import java.util.List; public class Student { public String name; public int age; public List& ...
- flutter vscode创建objc工程
通过vscode创建flutter工程时,默认创建的是swift项目工程,如果想要修改,可以通过vscode设置默认创建语言 1. Open vscode settings. Under User S ...
- log4j日志配置文件
log4j.properties: ### 设置### log4j.rootLogger = debug,stdout,D,E ### 输出信息到控制抬 ### log4j.appender.stdo ...
- 【转】一次HBase问题的解决过程(Status: INCONSISTENT)
[From]https://www.cnblogs.com/quchunhui/p/9583746.html ==版本信息== HBase:2.7.1 Storm:1.0.1 RocketMQ:3.4 ...
- 使用 WebStorm alt+f2 快速打开浏览器测试的一点bug
这个bug是涉及到中英文文件名的问题(不涉及到路径名): Case 1: 中文文件名 当打开alt+f2快捷方式打开含有中文名的html文件时,路径名直接变为localhost,所以找不到要打开的文件 ...
- XSS攻击总结
本文由 http://www.cnblogs.com/phpstudy2015-6/p/6767032.html 整理总结而来 XSS又称CSS(cross site script),译为跨站脚本攻击 ...
- 怎么在 localhost 下访问多个 Laravel 项目,通过一个IP访问多个项目(不仅仅是改变端口哦)
server { listen 80; server_name blog.sweetsunnyflower.com; index index.html index.htm index.php; cha ...
- Vue组件传值,父传子,子传父,非父子组件
vue3中传值方式: 1.父组件向子组件传值 父组件Blog.vue <template> <div id="blog"> <Alert v-if=& ...
- MATLAB灰色关联度分析
目录 1.释名 2.举例 3.操作步骤与原理详解 4.总结 5.附录:MATLAB代码 @ 1.释名 灰色关联度分析(Grey Relation Analysis,GRA),是一种多因素统计分析的方法 ...
- Leetcode之深度+广度优先搜索(DFS+BFS)专题-934. 最短的桥(Shortest Bridge)
Leetcode之广度优先搜索(BFS)专题-934. 最短的桥(Shortest Bridge) BFS入门详解:Leetcode之广度优先搜索(BFS)专题-429. N叉树的层序遍历(N-ary ...