linux上测试网络命令
时间: 2023-11-07 11:58:54 浏览: 149
以下是一些常用的网络命令,可以在Linux上进行测试:
1. ping:测试网络连接是否可达
例如,ping www.google.com:
```
$ ping www.google.com
PING www.google.com (172.217.26.36) 56(84) bytes of data.
64 bytes from ord37s08-in-f4.1e100.net (172.217.26.36): icmp_seq=1 ttl=117 time=13.7 ms
64 bytes from ord37s08-in-f4.1e100.net (172.217.26.36): icmp_seq=2 ttl=117 time=10.5 ms
64 bytes from ord37s08-in-f4.1e100.net (172.217.26.36): icmp_seq=3 ttl=117 time=11.7 ms
```
2. nslookup:查询DNS信息
例如,nslookup www.google.com:
```
$ nslookup www.google.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: www.google.com
Address: 172.217.26.36
```
3. traceroute:跟踪网络数据包的路径
例如,traceroute www.google.com:
```
$ traceroute www.google.com
traceroute to www.google.com (172.217.26.36), 30 hops max, 60 byte packets
1 gateway (192.168.1.1) 2.564 ms 2.673 ms 2.795 ms
2 10.10.10.1 (10.10.10.1) 3.496 ms 3.634 ms 3.719 ms
3 172.16.0.1 (172.16.0.1) 6.524 ms 6.644 ms 6.777 ms
4 10.10.20.1 (10.10.20.1) 12.599 ms 12.699 ms 12.834 ms
5 172.16.0.2 (172.16.0.2) 16.020 ms 16.154 ms 16.276 ms
6 209.85.242.65 (209.85.242.65) 20.591 ms 20.733 ms 20.873 ms
7 72.14.236.157 (72.14.236.157) 23.067 ms 23.207 ms 23.345 ms
8 72.14.239.253 (72.14.239.253) 25.587 ms 25.730 ms 25.871 ms
9 108.170.247.97 (108.170.247.97) 28.355 ms 28.494 ms 28.636 ms
10 ord37s08-in-f4.1e100.net (172.217.26.36) 31.021 ms 31.167 ms 31.304 ms
```
4. curl:测试HTTP请求
例如,curl www.google.com:
```
$ curl www.google.com
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/logos/doodles/2021/celebrating-50-years-of-kids-coding-6753651837108947-l.png" itemprop="image"><title>Google</title>...
```
5. wget:下载文件
例如,wget https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png:
```
$ wget https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png
--2021-08-18 12:00:00-- https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png
Resolving www.google.com (www.google.com)... 172.217.26.36, 2607:f8b0:4004:811::2004
Connecting to www.google.com (www.google.com)|172.217.26.36|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5861 (5.7K) [image/png]
Saving to: ‘googlelogo_color_92x30dp.png’
googlelogo_color_92x30dp.png 100%[======================================================>] 5.72K --.-KB/s in 0s
2021-08-18 12:00:00 (47.1 MB/s) - ‘googlelogo_color_92x30dp.png’ saved [5861/5861]
```
阅读全文