阳光之吻 2019-06-27
ping [选项] [域名或IP地址]
-c <完成次数>
:设置完成要求回应的次数;-i <间隔秒数>
:指定收发信息的间隔时间;-s <数据包大小>
:设置ICMP数据部分的大小;[vagrant@10 tmp]$ ping -c 3 -i 2 -s 100 www.baidu.com PING www.baidu.com (61.135.169.121) 100(128) bytes of data. 108 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=56 time=11.6 ms 108 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=56 time=7.36 ms 108 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=3 ttl=56 time=6.47 ms --- www.baidu.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 6.471/8.487/11.632/2.255 ms
\ | 解释 |
---|---|
www.baidu.com (61.135.169.121) | 目标主机的主机名和IP地址 |
100(128) bytes | ICMP数据部分的大小100字节 加上8字节的ICMP头,则ICMP包大小为108字节 再加上20字节的IP头,IP包大小为128字节 |
108 bytes | ICMP数据包大小 |
61.135.169.121 | 目标主机的IP地址 |
icmp_seq | ICMP包序号 |
ttl | 剩余生存时间 生存时间,是指数据包被路由器丢弃之前允许通过的网段数量。 TTL 是由发送主机设置的,以防止数据包不断在 IP 互联网络上永不终止地循环。转发 IP 数据包时,要求路由器至少将 TTL 减小 1。 |
time | 响应时间,这个时间越小,说明你连接这个地址速度越快 |
3 packets transmitted | 发送数据包的数量 |
3 received | 接收到的数据包的数量 |
0% packet loss | 数据包的丢失率 |
time 4006ms | 整个过程消耗的总时间 |
rtt min/avg/max/mdev | 最小响应时间/平均响应时间/最大响应时间/响应时间的平均差 |
这里我们主要介绍使用 telnet 探测远程端口是否开放。
telnet [域名或IP地址] [端口号]
man.linuxde.net
的 80端口、22端口、11211端口是否开放[root@10 vagrant]# telnet man.linuxde.net 80 Trying 192.250.198.125... Connected to man.linuxde.net. Escape character is '^]'. Connection closed by foreign host. [root@10 vagrant]# telnet man.linuxde.net 22 Trying 192.250.198.125... Connected to man.linuxde.net. Escape character is '^]'. SSH-2.0-OpenSSH_5.3 Protocol mismatch. Connection closed by foreign host. [root@10 vagrant]# telnet man.linuxde.net 11211 Trying 192.250.198.125... telnet: connect to address 192.250.198.125: Connection refused
可见,man.linuxde.net
开放了80端口、22端口,没有开放11211端口。
路由跟踪命令。用于追踪数据包在网络上的传输时的全部路径,它默认发送的数据包大小是40字节。
通过traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径。当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一样,但基本上来说大部分时候所走的路由是相同的。
traceroute 和 ping 命令一样,都是用 ICMP 协议。
部分节点可能会出现不通的情况,此时会出现 * * *
traceroute [选项] [域名或IP]
-n
:直接使用IP地址而非主机名称,速度更快[root@10 vagrant]# traceroute www.google.com traceroute to www.google.com (216.58.216.132), 30 hops max, 60 byte packets 1 ec2-50-112-0-6.us-west-2.compute.amazonaws.com (50.112.0.6) 20.061 ms ec2-50-112-0-26.us-west-2.compute.amazonaws.com (50.112.0.26) 22.021 ms ec2-50-112-0-16.us-west-2.compute.amazonaws.com (50.112.0.16) 13.175 ms 2 100.66.8.224 (100.66.8.224) 16.202 ms 100.66.8.28 (100.66.8.28) 21.064 ms 100.66.8.206 (100.66.8.206) 18.758 ms 3 100.66.10.0 (100.66.10.0) 11.659 ms 100.66.10.76 (100.66.10.76) 19.651 ms 100.66.10.206 (100.66.10.206) 20.616 ms 4 100.66.7.33 (100.66.7.33) 18.709 ms 100.66.6.35 (100.66.6.35) 14.456 ms 100.66.6.143 (100.66.6.143) 13.734 ms 5 100.66.4.155 (100.66.4.155) 12.962 ms 100.66.4.101 (100.66.4.101) 16.822 ms 100.66.4.43 (100.66.4.43) 10.394 ms 6 100.65.11.193 (100.65.11.193) 0.603 ms 100.65.8.193 (100.65.8.193) 0.315 ms 100.65.8.97 (100.65.8.97) 0.829 ms 7 52.93.240.26 (52.93.240.26) 0.605 ms 52.93.240.42 (52.93.240.42) 0.606 ms 0.555 ms 8 52.93.12.98 (52.93.12.98) 22.474 ms 52.93.12.134 (52.93.12.134) 25.651 ms 24.525 ms 9 52.93.12.125 (52.93.12.125) 0.670 ms 52.93.12.235 (52.93.12.235) 0.720 ms 52.93.12.161 (52.93.12.161) 0.620 ms 10 100.91.25.194 (100.91.25.194) 9.060 ms 100.91.25.84 (100.91.25.84) 8.406 ms 100.91.25.214 (100.91.25.214) 8.496 ms 11 54.239.45.126 (54.239.45.126) 10.438 ms 8.839 ms 54.239.42.195 (54.239.42.195) 8.165 ms 12 54.239.42.220 (54.239.42.220) 7.394 ms 100.91.139.53 (100.91.139.53) 7.085 ms 100.91.139.51 (100.91.139.51) 7.078 ms 13 52.95.52.196 (52.95.52.196) 6.492 ms 100.91.139.83 (100.91.139.83) 7.490 ms 100.91.139.101 (100.91.139.101) 9.663 ms 14 52.95.52.13 (52.95.52.13) 6.416 ms 52.95.52.232 (52.95.52.232) 7.480 ms 52.95.52.157 (52.95.52.157) 7.202 ms 15 52.95.216.103 (52.95.216.103) 6.107 ms 52.95.52.47 (52.95.52.47) 8.358 ms 8.385 ms 16 108.170.245.97 (108.170.245.97) 8.150 ms 8.163 ms 52.95.216.101 (52.95.216.101) 8.017 ms 17 209.85.240.253 (209.85.240.253) 6.260 ms 6.228 ms 108.170.245.113 (108.170.245.113) 7.949 ms 18 sea15s01-in-f132.1e100.net (216.58.216.132) 6.928 ms 209.85.240.253 (209.85.240.253) 7.060 ms sea15s01-in-f4.1e100.net (216.58.216.132) 6.910 ms
dig [选项]
-i<网络界面>:使用指定的网络截面送出数据包
-nn:将数据包中的域名和服务名转换为IP和端口号
-X:用十六进制和ASCII字码显示数据包内容
port <端口号>:指定监听的端口
[root@10 tmp]# tcpdump -i eth1 -nnX port 11211 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes 08:24:46.381529 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 823138355:823138356, ack 3518529694, win 2052, length 1 0x0000: 4500 0029 2b15 4000 4006 4c10 c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1833 d1b8 809e ..!X-g+.1..3.... 0x0020: 5018 0804 be50 0000 3100 0000 0000 P....P..1..... 08:24:46.381589 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 1, win 229, length 0 0x0000: 4500 0028 d629 4000 4006 a0fc c0a8 2158 E..(.)@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1834 ..!.+.-g....1..4 0x0020: 5010 00e5 c3c4 0000 P....... 08:24:47.021627 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 1:2, ack 1, win 2052, length 1 0x0000: 4500 0029 2b16 4000 4006 4c0f c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1834 d1b8 809e ..!X-g+.1..4.... 0x0020: 5018 0804 bd4f 0000 3200 0000 0000 P....O..2..... 08:24:47.021690 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 2, win 229, length 0 0x0000: 4500 0028 d62a 4000 4006 a0fb c0a8 2158 E..(.*@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1835 ..!.+.-g....1..5 0x0020: 5010 00e5 c3c4 0000 P....... 08:24:48.420408 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 2:3, ack 1, win 2052, length 1 0x0000: 4500 0029 2b17 4000 4006 4c0e c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1835 d1b8 809e ..!X-g+.1..5.... 0x0020: 5018 0804 bc4e 0000 3300 0000 0000 P....N..3..... 08:24:48.420468 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 3, win 229, length 0 0x0000: 4500 0028 d62b 4000 4006 a0fa c0a8 2158 E..(.+@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1836 ..!.+.-g....1..6 0x0020: 5010 00e5 c3c4 0000 P....... 08:24:50.196671 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 3:4, ack 1, win 2052, length 1 0x0000: 4500 0029 2b18 4000 4006 4c0d c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1836 d1b8 809e ..!X-g+.1..6.... 0x0020: 5018 0804 8e4d 0000 6100 0000 0000 P....M..a..... 08:24:50.196752 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 4, win 229, length 0 0x0000: 4500 0028 d62c 4000 4006 a0f9 c0a8 2158 E..(.,@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1837 ..!.+.-g....1..7 0x0020: 5010 00e5 c3c4 0000 P....... 08:24:52.212906 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 4:5, ack 1, win 2052, length 1 0x0000: 4500 0029 2b19 4000 4006 4c0c c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1837 d1b8 809e ..!X-g+.1..7.... 0x0020: 5018 0804 8d4c 0000 6200 0000 0000 P....L..b..... 08:24:52.212977 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 5, win 229, length 0 0x0000: 4500 0028 d62d 4000 4006 a0f8 c0a8 2158 E..(.-@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1838 ..!.+.-g....1..8 0x0020: 5010 00e5 c3c4 0000 P....... 08:24:52.356770 IP 192.168.33.1.11623 > 192.168.33.88.11211: Flags [P.], seq 5:6, ack 1, win 2052, length 1 0x0000: 4500 0029 2b1a 4000 4006 4c0b c0a8 2101 E..)+.@[email protected]...!. 0x0010: c0a8 2158 2d67 2bcb 3110 1838 d1b8 809e ..!X-g+.1..8.... 0x0020: 5018 0804 8c4b 0000 6300 0000 0000 P....K..c..... 08:24:52.356827 IP 192.168.33.88.11211 > 192.168.33.1.11623: Flags [.], ack 6, win 229, length 0 0x0000: 4500 0028 d62e 4000 4006 a0f7 c0a8 2158 E..(..@.@.....!X 0x0010: c0a8 2101 2bcb 2d67 d1b8 809e 3110 1839 ..!.+.-g....1..9 0x0020: 5010 00e5 c3c4 0000 P.......
因为设备或终端是遍布整个省或市,有的甚至是国外,如何高效的处理问题是当务之急,除了telnet还可以ssh使用crt软件登陆,telnet开启的话比较方便windows自带的cmd命令行下就可以运行。