1. Ping command
Ping is a highly used utility used to determine network connectivity. This is useful for determining whether the network is properly connected and the state of the network connection.
In a nutshell, ping is a test program. If ping works correctly, it can generally troubleshoot the network access layer, network card, Modem input and output lines, cables, and routers, thus narrowing the scope of the problem.
Ping displays the amount of time in milliseconds between sending a request and returning a reply. If the response time is short, it means that the datagram does not have to pass through too many routers or networks, and the connection speed is relatively fast. Ping also displays the Time To Live (TTL) value, which can be used To estimate how many routers a packet passes through.
The command format
Ping Host name ping Domain name Ping IP address
As shown in the figure, run the ping command to check the connectivity of the computer at IP address 210.43.16.17. In this case, the connection is normal. Four test packets were sent and received correctly.
Basic application of the ping command
Typically, users can use a series of ping commands to find out where the problem is or to verify that the network is working.
A typical detection sequence and corresponding possible faults are given below:
1) ping 127.0.0.1
If the test succeeds, the network adapter, TCP/IP, IP address, and subnet mask are correctly installed. If the test fails, there is a problem with the TCP/IP installation or setup.
② Ping the local IP address
If the test fails, it indicates that the local configuration or installation is faulty. You need to test, check, and remove network devices and communication media.
3 Ping other IP addresses on the LAN
If the test succeeds, the network adapter and carrier on the local network are running correctly. However, if zero echo replies are received, the subnet mask is incorrect or the network adapter is incorrectly configured or there is a problem with the cable system.
4 Ping the gateway IP address
This command, if answered correctly, indicates that the gateway router on the LAN is running and able to reply.
⑤ Ping the remote IP address
If the response is correct, the default gateway is used successfully. For dial-up users, it indicates that they can access the Internet successfully (but there may be problems with THE ISP’S DNS).
6. Ping localhost
Local host is the system’s network-reserved name, which is an alias for 127.0.0.1 that every computer should be able to convert to that address. Otherwise, there is a problem in the host file (/Windows/host).
⑦ Ping www.yahoo.com (a famous website domain name)
To Ping the domain name, the computer must first convert the domain name to an IP address, usually through a DNS server. If a fault occurs, it indicates that the IP address of the local DNS server is incorrectly configured or the DNS server accessed by the local DNS server is faulty
If all of the ping commands listed above work, there should be basically no problem for computers to communicate locally and remotely. However, the success of these commands does not mean that all of your network configurations are problem-free; for example, some subnet mask errors may not be detected using these methods.
Common parameter options of the ping command
Ping IP -t: continuously ping an IP address until the ping command is interrupted by pressing Ctrl+C.
Ping IP -l 2000: specifies a specific data length in the ping command (2000 bytes in this case) instead of the default 32 bytes.
Ping IP -n 20: Run the ping command for a specified number of times (20 in this example).
Note: with the widespread use of firewalls in the network, do not jump to conclusions when you ping another host or another host ping your host and it shows that the host is unreachable. This is best compared with the ping result of a “well set up” host.
- Ipconfig command
The ipconfig utility can be used to display setting values for the current TCP/IP configuration. This information is generally used to verify that manually configured TCP/IP Settings are correct.
Also, if your computer and your LAN are using DHCP, use the ipconfig command to see if your computer has successfully rented an IP address and, if so, what address it currently has. Network configuration information includes the IP address, subnet mask, and default gateway.
The most commonly used options are given below:
(1) ipconfig: When you run the ipconfig command without any parameters, the IP address, subnet mask, and default gateway value of each configured interface are displayed.
(2) IPconfig /all: When using the all option, ipconfig can display all configured and used additional information for DNS and WINS servers, and can display the physical address (MAC) embedded in the local network card. If the IP address is rented from the DHCP server, ipconfig displays the IP address assigned by the DHCP server and the expected expiration date of the leased IP address. The picture shows the result window of running ipconfig /all.
(3) IPconfig /release and ipconfig /renew: These two additional options can only be used in computers that rent IP addresses from DHCP servers. If ipconfig /release is entered, the leased IP addresses of all interfaces are re-delivered to the DHCP server (IP addresses are returned).
If the user types ipconfig /renew, the local computer tries to contact the DHCP server and rent an IP address. In most cases, the network card will be assigned the same IP address as before.
- Arp Command (Address Translation Protocol)
ARP is an important protocol in the TCP/IP protocol family and is used to determine the physical address of a network interface card (NIC) corresponding to an IP address.
Using the arp command, you can view the current contents of the ARP cache on a local computer or another computer. In addition, using the ARP command, you can manually set a static physical address/IP address pair for the network adapter. In this way, you can perform local static configuration for common hosts, such as the default gateway and local server, which helps reduce the amount of information on the network.
By default, the item in the ARP cache is dynamic, and ARP automatically adds the item whenever data is sent to a specified location and there is no current item in the cache at that time.
Common command options:
① ARP -A: used to view all items in the cache.
(2) ARP -A IP: If there are multiple network adapters, only arp cache items related to the interface are displayed by adding the IP address of the interface to arp -A.
③ ARp-s IP physical address: manually enter a static item into the ARP cache. The item will remain valid during computer boot, or the manually configured physical address will automatically update the item in the event of an error.
④ arp -d IP: Deletes a static item manually.
- Traceroute command
Master the skills of using the traceroute command to measure routes, that is, display the path of packets reaching the destination host.
The basic usage of the traceroute command is to type tracert host_name or tracert ip_address at the command prompt. Tracert is the name of traceroute in Windows.
The output has 5 columns:
The first column is the value describing the NTH hop of the path, that is, the serial number of the router along the path.
The second column is the first round trip delay;
The third column is the second round trip delay;
The fourth column is the third round trip delay;
The fifth column contains the name of the router and the IP address of its input port.
If the source received less than 3 packets from any given router (due to packet loss in the network), Traceroute puts an asterisk after the router number and reports back less than 3 round trips to that router.
In addition, the tracert command can be used to view the steps or routes taken by the network to connect to the site, and to locate the problem if it is a network failure.
Consider [Testing routing for large networks] :
(1) Try “ping www.sina.com.cn” several times to compare the obtained IP address of Sina. If the IP addresses obtained from the two pings are different, consider the cause (for example, load balancing). Then, run the tracert ip_address command for different IP addresses to check whether the analysis results are different.
(2) Perform traceroute test for a site in a large network and record the test results. Check whether the delay of the NTH hop is smaller than that of the n-1 hop. Try to analyze the reasons (hint: the role of each component of delay in the total delay can be considered separately).
(3) At different times of the day, the traceroute program was used to test the route from the fixed host to the remote fixed IP address multiple times. Analyze and compare the measurement data to see if there is any change in the route. If there are changes, should they be frequent?
- The route command
Most hosts typically reside on a network segment connected to only one router. Since there is only one router, there is no problem of choosing which router to use to send packets to the remote computer. The IP address of the router serves as the default gateway for all computers on the network segment.
However, when there are two or more routers on the network, users do not necessarily want to rely only on the default gateway. You might actually want some remote IP addresses to pass through a particular router and others to pass through another router.
In this case, the user needs routing information, which is stored in a routing table that is unique to each host and each router. Most routers use specialized routing protocols to exchange and dynamically update routing tables between routers. In some cases, however, items must be manually added to routing tables on routers and hosts. The route command is used to display, manually add, and modify routing table entries. The following options are available:
(1) Route print: This command is used to display the current item in the routing table. The output result on a single router network segment is shown in the figure.
(2) Route add: Run the route add command to add routing items to the routing table.
For example, if you want to set a route to destination network 209.99.32.33 that passes through five router network segments and passes through a local router whose IP address is 202.96.123.5 and subnet mask is 255.255.255.224, run the following command:
Route add 209.99.32.33 mask 255.255.255.224 202.96.123.5 metric 5
(3) Route change: You can use this command to change the route of data transmission. However, you cannot use this command to change the destination of data transmission. The following example changes the route from the previous example to a path with three network segments:
Route add 209.99.32.33 mask 255.255.255.224 202.96.123.250 metric 3
(4) Route delete: Run the route delete command to delete routes from the routing table. Example: Route delete 209.99.32.33
- Nslookup command
The nslookup command is used to query the IP address and domain name of any machine. It usually requires a domain name server to provide the domain name. If the DNS server has been configured, you can use this command to view the domain names corresponding to the IP addresses of different hosts.
(1) Run the nslookup command on the local computer to check the IP address and DNS server address of the local computer.
Enter the command directly, the system returns the server name (with the full name of the domain name) and IP address of the local host, and enters the operation command line state with > as the prompt. Type “?” You can query detailed command parameters. To exit, type Exit.
(2) View the IP address of www.haut.edu.cn. Enter the IP address or domain name after the prompt and press Enter.
- Nbtstat command
Use the nbtstat command to view some information about the network configuration on your computer. You can also use this command to find personal information on someone else’s computer.
To view network information on your computer, run nbtstat -n to get the workgroup you are in, the name of your computer, the address of your network card, and so on. To view other computers on the network, run nbtstat -a… Here… Substituting an IP address will return some information about that host.
- The netstat command
Learn to use the netstat command to learn about the current network status.
The netstat command displays active TCP connections, monitored ports, Ethernet statistics, IP routing tables, IPv4 statistics (for IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for IPv6, ICMPv6, and over IPv6) TCP and UDP protocols). When used without parameters, netstat displays active TCP connections.
Here are some common options for netstat:
The netstat -a option displays a list of all valid connections, including those that are ESTABLISHED and those that are LISTENING.
② netstat -n: Lists IP addresses in dotted decimal notation instead of symbolic host names and network names.
③ netstat -e: The -e option is used to display statistics about Ethernet. It lists the total number of bytes of packets transmitted, errors, deletions, number of packets, and number of broadcasts. These statistics include both the number of packets sent and the number of packets received. Use this option to count some basic network traffic.
④ Netstat -r: The -r option displays information about the routing table, similar to the information in the route print command. In addition to displaying valid routes, the currently valid connections are also displayed.
The figure above shows a routing table where Network Destination indicates the Destination Network and 0.0.0.0 indicates the unknown Network, which is automatically generated by the system after the default gateway is set. 127.0.0.0 indicates the local network address for testing. 224.0.0.0 indicates the multicast address. 255.255.255.255 limits broadcast addresses. Netmask indicates the network mask, Gateway indicates the Gateway, Interface indicates the Interface address, and Metric indicates the hop count of the route.
⑤ Netstat -s: the -s option displays statistics for each protocol. This allows you to see what connections your computer currently has on the network, the details of packets being sent and received, and so on. If your application, such as a Web browser, is slow or cannot display data such as Web pages, you can use this option to see what information is displayed. Identify the problem by scrutinizing the rows of statistics to find the keywords that went wrong.
- Net command
Understand the function of Net service, learn to use Net service command to solve network problems.
To get syntax help for net commands, type NET help command on the command line. For example, to get help about the NET Accounts command, type “Net Help Accounts.”
All NET commands can use the /y and /n command-line options. For example, the net stop server command is used to prompt the user to stop all dependent server services. The net stop server/y command is used to stop and stop all dependent server services.
The following table lists the basic NET commands and what they do:
The NET command provides all the information in one place and redirects the results to a printer or to a standard text file.
Many of the network commands used by services start with NET, and these NET commands have some common properties. To see a list of all available NET commands, type net/? In a command prompt window.