ipconfig

In Windows, if you add /all to ipconfig, you can view the IP address, mask, default gateway, DHCP server, and DNS server information of the local host. In Linux or Mac, run the 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.......... : 24 May 2021 14:26:49 Lease Expires.......... :25 May 2021 14:12:25 Default Gateway......... : 172.16.13.1 DHCP Server.......... : 172.16.13.1 DHCPv6 great significance by 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 HOSTCopy the code

ping

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

  1. Judge whether the network connection is smooth;

  2. Obtain the IP address of a domain name.

  3. The response speed of the network is obtained according to the time value.

  4. Determine the number of routers through which the packet passes according to the TTL value.

    Macbook :~ Aaron $ping baidu.com Ping baidu.com (220.181.baidu.com): 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= 7297ms ping statistics — 7 packets transmitted, 4 packets received 0.0% packet loss round – trip min/avg/Max/stddev 34.663/0.991 = 32.157/32.971 / ms

By ping baidu’s domain name, the IP address is 220.181.38.148. If the response time is less than 50 ms, the network speed is normal.

As mentioned in the previous article, forwarding data between different network segments is done by routers. The TTL is short for Time To Live. It indicates the maximum number of network segments allowed To pass IP packets before they are discarded by the router. The initial value may vary from operating system to operating system, but it is 2 to the N.

Here, we use the nearest value of 52, 64, which is 2^6, as the initial value, so the number of routers we pass through can be calculated as 64-52=12.

telnet

You can run the Telnet command to check whether services are running on a certain port of the remote host. This command is unavailable in Windows by default. You can install it in the control panel. If there is no response, ensure that the port on 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 '^]'Copy the code

tracert

It is used to detect the number of routers that reach the target host. It uses ICMP protocol to work and helps us locate which node in the network has a problem. First, it sends a packet with a TTL (time to live) of 1 to the target host. The first router that handles the packet reduces the TTL value by 1, then dismisses the 0 datagram and returns an ICMP message containing the router’s IP address. Subsequently, the TTL value is successively increased, and the sent response will reach more routers until it fails or ends. In Linux, run 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 *Copy the code

-q indicates that one packet is sent at a time; The line indicated by the asterisk may be because the firewall blocks the ICMP response.