ipconfig

Under Windows system, add the /all parameter to ipconfig to view the IP address, mask, default gateway, DHCP and DNS server information of the machine. Under Linux or Mac system, please use ifconfig command instead.

C:\Users\admin>ipconfig /all
Windows IP Configuration
Ethernet adapter Ethernet0:
   Connection-specific DNS Suffix  . : DHCP
   Description . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection
   Physical Address. . . . . . . . . : 00-0C-29-A8-3E-AA
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::547b:2b11:b2bd:3cfb%15(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.16.13.3(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : 2021年5月24日 14:26:49
   Lease Expires . . . . . . . . . . : 2021年5月25日 14:12:25
   Default Gateway . . . . . . . . . : 172.16.13.1
   DHCP Server . . . . . . . . . . . : 172.16.13.1
   DHCPv6 IAID . . . . . . . . . . . : 117443625
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-1B-98-1F-00-0C-29-A8-3E-AA
   DNS Servers . . . . . . . . . . . : 172.16.13.1
   NetBIOS over Tcpip. . . . . . . . : Enabled
   Connection-specific DNS Suffix Search List :
                                       DHCP
                                       HOST

ping

It can be used to detect the connectivity to another host and obtain the following information. Note that some machines may disable the ICMP protocol used by ping, resulting in no response.

判断网络连接是否通畅;
获取某个域名的IP地址;
根据time值获取网络的响应速度;
根据ttl值判断数据包经过的路由器数量。

macbook:~ aaron$ ping baidu.com
PING baidu.com (220.181.38.148): 56 data bytes
64 bytes from 220.181.38.148: icmp_seq=0 ttl=52 time=32.157 ms
64 bytes from 220.181.38.148: icmp_seq=1 ttl=52 time=34.663 ms
64 bytes from 220.181.38.148: icmp_seq=2 ttl=52 time=32.626 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 32.157/32.971/34.663/0.991 ms

The IP address obtained by pinging Baidu’s domain name above is 220.181.38.148; the response time is less than 50 milliseconds, indicating that the network speed is normal.

In the previous article, we mentioned that the router is responsible for forwarding data between different network segments. The TTL here is the abbreviation of Time To Live, which means the maximum number of network segments allowed to pass through before the IP packet is discarded by the router. Different operating systems may have different initial values, but they are all 2 to the Nth power.

Here, we use the 64 nearest to the return value 52, that is, 2^6 as the initial value. Then, the number of routers passing by on the way can be calculated with 64-52=12.

telent

Use the telnet command to check whether there is a service running on a certain port of the remote host. The Windows system does not have this command by default and can be installed in the control panel. If there is no response, please make sure that the port of the remote server is not disabled by the firewall.

macbook:~ aaron$ telnet 39.156.69.79 80
Trying 39.156.69.79...
Connected to 39.156.69.79.
Escape character is '^]'

macbook:~ aaron$ telnet 39.156.69.79 80
Trying 39.156.69.79...
Connected to 39.156.69.79.
Escape character is '^]'

tracert

It is used to detect the number of routers passing by to reach the target host. It uses the ICMP protocol to work and can help us locate which node in the network has a problem.
First, it will send a packet with a TTL (time to live) of 1 to the target host. The first router to process this packet will subtract 1 from the TTL value, then discard the datagram that is already 0 and return a packet containing ICMP packet of router IP address. Subsequently, the TTL value is increased in sequence, and the response sent will reach more routers until it fails or ends.
Under Linux, please use the traceroute command instead.

macbook:~ aaron$ traceroute -q 1 114.114.114.114
traceroute to 114.114.114.114 (114.114.114.114), 64 hops max, 52 byte packets
 1  192.168.0.1 (192.168.0.1)  2.908 ms
 2  192.168.1.1 (192.168.1.1)  3.831 ms
 3  58.208.178.1 (58.208.178.1)  5.278 ms
 4  218.4.30.205 (218.4.30.205)  7.611 ms
 5  221.224.235.61 (221.224.235.61)  7.858 ms
 6  10.255.61.9 (10.255.61.9)  8.547 ms
 7  61.155.228.158 (61.155.228.158)  13.068 ms
 8  *
 9  *

Here -q means sending one packet at a time; the line indicated by the asterisk may be because the firewall blocked the ICMP response.

thematic catalog


陈哥聊测试
158 声望3.3k 粉丝

资深敏捷测试顾问,国内知名项目管理软件禅道团队成员。