1.ping命令
Ping is a highly used utility that is used to determine network connectivity. Ping is able to display latency in milliseconds. If the answer time is short, it means that the datagram does not have to go through too many routers or networks, and the connection speed is relatively fast. Ping can also display the TTL (Time To Live) value, which can be used to calculate how many routers the packet has passed.
(1) Command format
ping the IP address
Ping the domain name
As shown in the figure, the ping command was used to check the connectivity to the Baidu website, a total of four test packets were sent, and four packets were received correctly.
(2) Basic application of ping command
Open the cmd command window on your Windows computer and type ping /? After pressing enter, you can view the detailed ping command format and option description. The following ping commands are commonly used in Windows:
- 不间断ping:ping + IP地址/域名 + –t
- It can be used for long-term ping test, observe network stability, and press Ctrl+C to interrupt the test;
- For example: ping www.qq.com -t
- ping大包:ping + IP地址/域名 + –l +字节数
- It can be used for ping large packet tests, and can also be used to create burst traffic;
- ping www.qq.com -l 1300 #以1300字节为例ping测试QQ网站连通性
- 指定源地址Ping:ping +域名 + -S +接口IP
- It can be used to specify egress ping connectivity when the computer is configured with multiple network adapters or IPs;
- ping www.qq.com -S 192.168.1.11 #指定IP为192.168.1.1的有线/无线网卡ping QQ站点连通性
- ping固定数量包:ping +域名 + -n +数据包数量
- It can be used to ping a specified number of times to calculate the average latency.
- For example, ping www.qq.com -n 10 uses 10 packets as an example
2. ipconfig command
The ipconfig utility can be used to display the set values for the current TCP/IP configuration. This information is generally used to verify that the manually configured TCP/IP settings are correct.
In addition, if the computer and the LAN are using the dynamic host configuration protocol DHCP, you can use the ipconfig command to find out whether your computer has successfully leased an IP address, and if so, you can find out what address it has obtained, including IP address, subnet mask, default gateway and other network configuration information. The following figure shows the parameters of the NIC after ipconfig/all is entered:
The following is the commonly used ipconfig command on Windows:
- ipconfig
Displays the IP address, subnet mask, and default gateway of each configured NIC. It is commonly used to check whether all network IP addresses of all NICs are normal when the Internet cannot be accessed.
- ipconfig /all
Displays the complete network parameters of each configured NIC, including interface MAC addresses and DNS servers. If the IP is obtained by DHCP, the DHCP server and the remaining time of the lease period are also included.
- ipconfig /release 和 ipconfig /renew
It works when the computer is automatically getting the IP. ipconfig /release is to release all the IP parameters that are currently obtained, and ipconfig /renew is to request the IP parameters from the DHCP server again.
It is often used to quickly release and re-obtain network parameters when the DHCP server changes or other network faults occur.
- ipconfig /flushdns
Clear your computer's local DNS cache. It can be used to help diagnose Internet access anomalies caused by DNS anomalies caused by excessive or incorrect DNS caches.
3. ARP命令
Address Resolution Protocol (ARP) is a network-layer protocol that obtains MAC addresses based on IP addresses in IPv4 networks. Different devices in the LAN are generally accessed through IP addresses, and all data transmission depends on the underlying hardware of the network card, that is, the data link layer; Therefore, the ARP protocol is required to resolve the IP address in the network layer into a MAC address that can be recognized by the link layer to ensure the smooth progress of communication. (Welcome.)
Common Command Options:
- arp –a: Used to view all ARP entries in the cache, and when an IP address on the local area network is not available, you can first query whether the ARP information is learned, or query the correctness of the gateway MAC address.
- arp -a IP: If there are multiple NICs, you can use arp -a plus the IP address of the interface to display only the ARP cache items related to the interface.
- arp -s IP 物理地址
- 例如:arp –s 192.168.1.3 11-22-33-44-55-77
- Manually enter a static item into the ARP cache. The item will remain valid during the computer boot process, or in the event of an error, the manually configured physical address will automatically update the item.
- arp -d IP: You can manually delete a static project by using this command.
4. traceroute命令
Gain the skill of using the traceroute command to measure routing, which is used to show the path a packet takes to reach the destination host. The basic usage of the traceroute command is to type "tracert host_name" or "tracert ip_address" after the command prompt, where tracert is the name of traceroute on the Windows operating system.
The output has 5 columns:
The first column is the numeric value describing the nth hop of the path, that is, the router sequence number 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 is the name of the router and the IP address of its input port.
If the source receives 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 less than 3 round-trip times to that router.
Open the cmd command window on a Windows computer, enter tracert, and press enter to view the detailed tracert command format and option description. The following table describes the commonly used tracert commands and usage scenarios in Windows:
- tracert + domain name
- To trace the route of the destination network, DNS will be used to resolve the hostname of the destination IP address and display it by default.
- tracert www.baidu.com
- tracert –d + 域名
- When the traceroute process does not resolve the hostname, the tracert waiting time can be significantly shortened.
- tracert –d www.baidu.com
- tracert –S+ IP地址+ 域名
- If a host has multiple IP addresses, you can specify the source IP address for traceroute.
- tracert –S 192.168.1.10 www.baidu.com
5. route command
For example, if you want to access 10.0.0.0/24 and I want to use 192.168.1.254 instead of confirm gateway 192.168.1.1, you can modify the route table to meet the specified access requirements. The route command is used to display, manually add, and modify route table items. The command has the following options:
- route print: This command is used to display the current items in the route table, and the output result on a single router network segment is shown in the figure.
- route add: You can use this command to add a static route entry.
- The next hop destined for the destination CIDR block 10.10.10.0/24 is 192.168.1.254, and the number of route hops is 5 (the smaller the better), as follows:
- route add 10.10.10.1 mask 255.255.255.0 192.168.1.254 metric 5
- route delete: You can use this command to delete a route from the route table.
- route delete 10.10.10.1
6. nslookup命令
The function of the nslookup command is to query the IP address of any machine and its corresponding domain name. It usually requires a nameserver to serve the domain name. If the user has already set up the name server, you can use this command to view the domain name corresponding to the IP address of different hosts.
The common nslookup commands and usage scenarios in Windows are as follows:
- nslookup
View the default DNS server of the current system.
Directly type the command, the system returns the server name (full name with domain name) and IP address of the machine, and enters the operation command line state with ">" as the prompt; Type "? You can query the detailed command parameters; To exit, type exit or Ctrl+C
- nslookup + 域名
- If the terminal cannot open the web page, you can use the default DNS server to query the specified domain name and determine whether the current DNS server is normal based on the query results.
- nslookup www.baidu.com
- nslookup + 域名+ DNS服务器IP
- If you want to compare domain name queries between different DNS servers, you can use a specified DNS server to query domain names.
- www.baidu.com 114.114.114.114
7. NBTSTAT命令
Use the nbtstat command to view some information about the network configuration on your computer. You can also use this command to find out some private information on someone else's computer. If you want to view the network information on your computer, you can run nbtstat -n to get the workgroup you are in, the computer name, the network card address, etc.; If you want to see what is going on on other computers on the network, run nbtstat -a..., and replace the IP address with *...* here to return some information on that host.
8. telnet command
There are usually two ways to say telnet, one is the standard protocol of TCP/IP, and the other is used as a remote login tool. We are talking about commands with the network diagnosis function when using telnet as a tool. telnet is usually used to detect whether a TCP port is reachable, so as to help determine the problem of a network application.
Open the cmd command window on a Windows computer, type telnet, press enter, and then enter? You can see the detailed telnet command format and option descriptions.
The following are the commonly used telnet commands in Windows:
- telnet + IP/域名
- If only the IP address is entered, the connection is established with the default telnet port 23 of the IP.
- telnet www.baidu.com
- telnet +IP/域名+ 端口
- The form of telnet+IP+ port is to establish a TCP connection with this port of this IP address through the telnet protocol.
- telnet www.baidu.com 443
9. netstat Command
Learn to use the netstat command to understand the current state of the network.
The netstat command displays active TCP connections, ports on which the computer listens, Ethernet statistics, IP routing tables, IPv4 statistics (for IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for IPv6, ICMPv6, TCP over IPv6, and UDP protocols). When used, netstat shows the active TCP connection without a parameter.
Some of the common options for netstat are given below:
- (1) The netstat –a:-a option displays a list of all valid connections, including those that have been established and those that are listening for connection requests.
- (2) netstat –n: Lists IP addresses in dotted decimal form instead of symbolic hostnames and network names.
- (3) netstat -e:-e option is used to display statistics about Ethernet. It lists items such as the total number of bytes of packets transmitted, the number of errors, the number of deletions, the number of packets, and the 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.
- (4) The netstat -r:-r option can display information about the route table, similar to the information you see when you run the route print command. In addition to displaying valid routes, it also displays the connections that are currently valid.
- The preceding figure shows a routing table, in which Network Destination represents the destination network and 0.0.0.0 represents an unknown network, which is automatically generated by the system after the default gateway is set. 127.0.0.0 represents the native network address and is used for testing; 224.0.0.0 indicates a multicast address; 255.255.255.255 indicates a restricted broadcast address; Netmask indicates the netmask, Gateway indicates the gateway, Interface indicates the interface address, and Metric indicates the number of route hops.
- (5) The netstat -s:-s option can display the statistics of each protocol separately. This allows you to see what connections your computer currently has on the network, details of packet sending and receiving, and more. If your application (e.g., a web browser) is slow or cannot display data such as web pages, you can use this option to view the information displayed. Carefully look at the rows of the stats to find the keywords that are going wrong and identify the problem.
10. .net command
Understand the functions of the Net service and learn how to use the Net service command to solve network problems. You can type net help command on the command line to get syntax help for the net command on the command line. For example, to get help with the net accounts command, type "net help accounts".
The /y and /n command-line options are available for all net commands. For example, the net stop server command is used to prompt the user to confirm the stop of all dependent server services, and the net stop server/y indicates that the server service is stopped and shut down.
The following table lists the basic .NET commands and what they do:
order | example | function |
NET ACCOUNTS | NET ACCOUNTS | Review your current account settings |
NET CONFIG | NET CONFIG SERVER | Check the statistics of the network configuration information |
NET GROUP | NET GROUP | Consult Domain Groups (on Domain Controllers) |
NET PRINT | NET PRINT\printserver\printer1 | Review or modify the printer mapping |
NET SEND | NET SEND server1 “test message” | Send or broadcast messages to other computers |
NET SHARE | NET SHARE | Consult shared files on your local computer |
NET START | NET START Messenger | Start the service |
NET STATISTICS | NET STATISTICS SERVER | View network traffic statistics |
NET STOP | NET STOP Messenger | Discontinuation of service |
NET USE | NET USE x:\server1\admin | Map network share files to a drive letter |
NET USER | NET USER | Check the local user account |
NET VIEW | NET VIEW | Check which computers are available on the network |
The results of .NET command execution are similar to those obtained by other Windows Server 2003 management tools. However, the .NET command can provide all the information in one place and can redirect the results to a printer or a standard text file. Many services use network commands that start with net, and these net commands have some common properties. To see a list of all available net commands, you can get by typing net/?, in the command prompt window.
11. Netsh network parameter configuration command
Netsh has powerful features that can be used to complete both static and dynamic configuration of network parameters. There are two ways to use this command - hang command and hierarchical command. In the pass-through command mode, enter all commands and parameters in a line, press enter to execute, and exit the netsh command. After entering the netsh command, select the sub-commands to be executed step by step, and after the execution is completed, it will still be in the netsh command environment, and you need to enter q or exit to exit.
Basic Usage:
netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *] [Command | -f ScriptFile]
1. Subcommand after entering netsh
order | interpretation |
? | A list of commands is displayed. |
abort | Discard changes made in offline mode |
add | Add a configuration item to the project list |
advfirewall | 更改到 `netsh advfirewall' 上下文 |
alias | Add an alias |
bridge | 更改到 `netsh bridge' 上下文 |
bye | Exit the program |
commit | Commit the changes you made in offline mode |
delete | Deletes a configuration item from the project list |
dhcpclient | 更改到 `netsh dhcpclient' 上下文 |
dnsclient | 更改到 `netsh dnsclient' 上下文 |
dump | A configuration script is displayed |
exit | Exit the program |
firewall | 更改到 `netsh firewall' 上下文 |
help | A list of commands is displayed |
http | 更改到 `netsh http' 上下文 |
interface | 更改到 `netsh interface' 上下文 |
ipsec | 更改到 `netsh ipsec' 上下文 |
work | Change to the 'netsh lan' context |
mbn | Change to the 'netsh mbn' context |
namespace | 更改到 `netsh namespace' 上下文 |
Netio | Change to the 'netsh netio' context |
nlm | 更改到 `netsh nlm' 上下文 |
offline | Set the current mode to offline |
online | Set the current mode to online |
P2P | 更改到 `netsh p2p' 上下文 |
popd | Open a context from the stack |
pushd | Put the current context into the stack |
quit | Exit the program |
ras | Change to the 'netsh ras' context |
rpc | Change to the 'netsh rpc' context |
set | Update configuration settings |
show | Display information |
trace | 更改到 `netsh trace' 上下文 |
unalias | Delete an alias |
wcn | Change to the 'netsh wcn' context |
wfp | Change to the 'netsh wfp' context |
winhttp | 更改到 `netsh winsock' 上下文 |
winsock | 更改到 `netsh winsock' 上下文 |
wireless | Change to the 'netsh WLAN' context |
2. Network configuration
(1)显示网络接口参数信息:netsh interface ip show sth,其中sth的类型如下:
address | Displays the IP address configuration. |
config | Displays IP address and more information. |
dns | Displays the DNS server address. |
icmp | Displays ICMP statistics. |
interface | Displays statistics on IP interfaces. |
ipaddress | Displays the current IP address. |
ipnet | Displays the network-to-media mapping of the IP. |
ipstats | Displays IP statistics. |
joins | Displays the joined multicast group. |
offload | Displays uninstall information. |
tcpconn | TCP connections are displayed. |
tcpstats | Displays TCP statistics. |
udpconn | UDP connection is displayed. |
udpstats | UDP statistics are displayed. |
wins | The WINS server address is displayed. |
(2) 配置接口IP/网关IP
用法:netsh interface ip set address+网络名称+自动(dhcp)/静态(static)+IP地址+掩码+网关+跃点数,如下:
netsh interface ip set address "本地连接" static 192.168.1.200 255.255.255.0 192.168.1.1 5
You can also modify the IP address, DNS address, and WINS address of the network connection separately (corresponding to the above three addresses, netmask, and gateway)
>> 自动ip(DHCP):
netsh interface ip set address "本地连接" dhcp #本地连接的IP地址自动获取
netsh interface ip set dns "本地连接" dhcp #本地连接的DNS地址自动获取
netsh interface ip set wins "本地连接" dhcp #本地连接的WINS地址自动获取
>> Static IP:
netsh interface ip set address "本地连接" static 192.168.1.1 #本地连接的IP地址静态配置
netsh interface ip set dns "本地连接" static 8.8.8.8 #本地连接的DNS地址静态配置
netsh interface ip set wins "本地连接" static 1.0.0.0 #本地连接的WINS地址静态配置
3. Firewall related commands
Common commands:
netsh firewall show state | View the status of your firewall |
netsh firewall set opmode disable | Disable the system firewall |
netsh firewall set opmode enable | Enable the firewall |