linux 测试网络url命令

烈酒焚心 提交于 2020-03-25 15:08:26

1.curl 地址 或者 wget url地址

[hxxxx@iZ23vy2msooZ ~]$ curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>鐧惧害涓€涓嬶紝浣犲氨鐭ラ亾</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class="head_wrapper"> <div class="s_form"> <div class="s_form_wrapper"> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class="fm"> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class="s_ipt" value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=鐧惧害涓€涓class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class="mnav">鏂伴椈</a> <a href=http://www.hao123.com name=tj_trhao123 class="mnav">hao123</a> <a href=http://map.baidu.com name=tj_trmap class="mnav">鍦板浘</a> <a href=http://v.baidu.com name=tj_trvideo class="mnav">瑙嗛</a> <a href=http://tieba.baidu.com name=tj_trtieba class="mnav">璐村惂</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class="lb">鐧诲綍</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">鐧诲綍</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class="bri" style="display: block;">鏇村浜у搧</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>鍏充簬鐧惧害</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>浣跨敤鐧惧害鍓嶅繀璇/a>&nbsp; <a href=http://jianyi.baidu.com/ class="cp-feedback">鎰忚鍙嶉</a>&nbsp;浜琁CP璇30173鍙nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>

 

 wget + 空格 + 要下载文件的url路径

[hxxxx@iZ23vy2msooZ ~]$ wget www.baidu.com
--2017-03-18 23:05:54-- http://www.baidu.com/
Resolving www.baidu.com... 220.181.112.244, 220.181.111.188
Connecting to www.baidu.com|220.181.112.244|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2381 (2.3K) [text/html]
Saving to: 鈥渋ndex.html.1鈥

100%[=============================================================================================================================>] 2,381 --.-K/s in 0s

2017-03-18 23:05:54 (317 MB/s) - 鈥渋ndex.html.1鈥saved [2381/2381]

2.ping ip地址  ctrl+c退出   ping只是测试网络联接状况以及信息包发送和接收状况。

[hxxxx@iZ23vy2msooZ ~]$ ping www.baidu.com
PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
64 bytes from 220.181.111.188: icmp_seq=1 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=2 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=3 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=4 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=5 ttl=53 time=28.8 ms
64 bytes from 220.181.111.188: icmp_seq=6 ttl=53 time=28.8 ms
64 bytes from 220.181.111.188: icmp_seq=7 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=8 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=9 ttl=53 time=28.8 ms
64 bytes from 220.181.111.188: icmp_seq=10 ttl=53 time=28.7 ms
64 bytes from 220.181.111.188: icmp_seq=11 ttl=53 time=28.8 ms
^C
--- www.a.shifen.com ping statistics ---
11 packets transmitted, 11 received, 0% packet loss, time 10445ms
rtt min/avg/max/mdev = 28.748/28.801/28.892/0.148 ms

 

3.telnet ip地址 端口地址

[hxxxx@iZ23vy2msooZ ~]$ telnet www.baidu.com 80
Trying 220.181.112.244...
Connected to www.baidu.com.
Escape character is '^]'.
^C
Connection closed by foreign host.
[hxxxx@iZ23vy2msooZ ~]$ telnet www.baidu.com 443
Trying 220.181.112.244...
Connected to www.baidu.com.
Escape character is '^]'.
^C
^CConnection closed by foreign host.

 

4.可以使用traceroute命令显示数据包到达目的主机所经过的路由。

[hxxxx@iZ23vy2msooZ ~]$ traceroute www.baidu.com
traceroute to www.baidu.com (220.181.111.188), 30 hops max, 60 byte packets
1 * * *
2 11.240.157.150 (11.240.157.150) 4.258 ms 11.240.144.214 (11.240.144.214) 1.127 ms 11.240.163.246 (11.240.163.246) 4.312 ms
3 140.205.27.210 (140.205.27.210) 2.072 ms 42.120.244.237 (42.120.244.237) 2.452 ms 106.11.144.33 (106.11.144.33) 1.178 ms
4 42.120.247.98 (42.120.247.98) 2.800 ms 42.120.247.110 (42.120.247.110) 1.142 ms 42.120.247.66 (42.120.247.66) 22.146 ms
5 * * 115.238.21.114 (115.238.21.114) 0.980 ms
6 220.191.200.77 (220.191.200.77) 1.837 ms 220.191.200.73 (220.191.200.73) 7.704 ms 220.191.200.125 (220.191.200.125) 1.119 ms
7 * * 202.97.68.165 (202.97.68.165) 23.180 ms
8 * * *
9 * * *
10 220.181.182.26 (220.181.182.26) 23.839 ms 220.181.17.94 (220.181.17.94) 23.776 ms 220.181.17.150 (220.181.17.150) 29.032 ms

5.可以使用ifconfig命令来配置并查看网络接口的配置情况。

[huangjing@iZ23vy2msooZ ~]$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:01:02:33
inet addr:10.45.54.21 Bcast:10.45.55.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:343207526 errors:0 dropped:0 overruns:0 frame:0
TX packets:100026499 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57272669908 (53.3 GiB) TX bytes:142400917670 (132.6 GiB)

eth1 Link encap:Ethernet HWaddr 00:16:3E:01:13:EC
inet addr:114.55.11.127 Bcast:114.55.11.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1246009498 errors:0 dropped:0 overruns:0 frame:0
TX packets:945009458 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:304700165950 (283.7 GiB) TX bytes:339907719362 (316.5 GiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:123 errors:0 dropped:0 overruns:0 frame:0
TX packets:123 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7975 (7.7 KiB) TX bytes:7975 (7.7 KiB)

6.显示TCP/UDP传输协议的连接状态

[hxxxx@iZ23vy2msooZ ~]$ netstat -u  netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State

7.

[hxxxx@iZ23vy2msooZ ~]$ netstat -an | grep 7064
tcp 0 0 0.0.0.0:7064 0.0.0.0:* LISTEN
tcp 0 0 10.45.54.21:7064 100.97.54.29:6688 ESTABLISHED

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!