命令提示符(Command Prompt)证明自己是运行基本命令的最佳工具之一,这些命令允许您从Windows处理文件和文件夹。但是,命令提示符(Command Prompt)的功能远不止于此。您可以通过运行一些高级命令(包括一系列方便的网络命令)将事情提升到一个新的水平。今天,我们将学习如何使用命令提示符(Command Prompt)来检查 Internet 连接、网络连接、查看有关网络设备的信息以及查看 PC 与其他设备之间的连接。事不宜迟,让我们开始吧:
注意:(NOTE:)我们使用带有2019 年 11 月(November 2019)更新的(Update)Windows 10编写了本指南。但是,说明的所有命令在Windows 8.1和Windows 7中的工作方式相同。在继续之前,如果您不知道如何打开命令提示符(Command Prompt),请阅读:在 Windows 中启动命令提示符的 11 种方法(11 ways to launch the Command Prompt in Windows)。
1.如何在CMD中查看网络连接(CMD)
要检查您的 Internet 连接是否正常,您可以使用命令提示符(Command Prompt)来测试您与某个网站或 Internet 位置的连接。为此,您可以使用ping network 命令,后跟网址或 IP 地址。例如,您可以通过键入命令“ping www.digitalcitizen.life”来检查与("ping www.digitalcitizen.life.")Digital Citizen的连接,而无需打开 Web 浏览器。然后按键盘上的Enter 。
如果 ping 统计信息未显示任何数据包丢失,则表明您的 Internet 连接正常工作。但是,如果您丢失了数据包,则意味着您的 Internet 连接已断开,或者您 ping 的网站不在线。要仔细检查您的 Internet 连接,请至少 ping 另一个网站,最好是始终打开的网站,例如www.google.com。
ping命令还允许您使用方便的“ -t”参数,该参数使您可以永久 ping 指定地址,直到它被手动停止。例如,我们输入“ping -t www.digitalcitizen.life”。一段时间后,我们想查看一些连接统计信息,我们使用了键盘组合"CTRL + Break."这显示了在此之前运行的 ping 命令的平均值。
最后,我们使用键盘组合"CTRL + C."这将停止对指定地址执行 ping 命令的无限循环。
2.如何使用CMD(CMD)查看我电脑上的所有网卡?
要获取有关网络适配器和连接的详细信息,请使用ipconfig命令。打开命令提示符(Command Prompt),输入ipconfig,然后按Enter。正如您在下面的屏幕截图中看到的,当您运行此命令时,Windows会显示所有活动网络设备的列表,无论它们是连接还是断开,以及它们的 IP 地址。您还可以获得详细信息,例如它们的默认网关 IP 地址、子网掩码(gateway IP addresses, subnet masks)和每个网络适配器的状态。
如果将/all开关添加到ipconfig命令,您可以获得全新的详细信息:DNS 信息(DNS information)、MAC(媒体访问控制)(MAC (Media Access Control))(在物理地址(Physical Address)字段中)以及有关每个网络组件的其他信息。查看下图以查看从"ipconfig /all"命令获得的示例。
3.如何在CMD中检查你的网络连接(CMD)
如果要检查与路由器的网络连接是否正常运行,可以使用命令ipconfig和ping的组合。首先,获取有关您的适配器的一些cmd nic 信息。(cmd nic info)换句话说,打开命令提示符(Command Prompt)并运行ipconfig。在结果列表中,确定用于连接到要测试的网络的网络适配器。然后,在其详细信息中,找到路由器的 IP 地址并记下它。例如,如果我们想检查我们的以太网(Ethernet)网络连接,我们会运行ipconfig并看到我们路由器的 IP 地址是 192.168.50.1。
下一步是检查路由器和电脑之间的网络连接是否正常。为此,对路由器的 IP 地址运行ping命令就足够了。(ping)在我们的示例中,这意味着我们必须在CMD中运行此命令:ping 192.168.50.1。
如果没有丢包,则测试的网络连接运行良好。否则,您的计算机和路由器之间存在问题,在这种情况下,您应该检查您的 PC 的网络适配器是否配置正确,以太网(Ethernet)电缆是否正常(如果您使用的是有线连接),以及路由器是否正确正确配置。
4.如何更新网卡的IP地址
当您的网络连接无法正常工作时,您的网络适配器可能没有分配正确的 IP 地址。尝试解决此问题的一种快速方法是更新其 IP 地址,幸运的是,您可以直接从命令提示符(Command Prompt)快速执行此操作。打开CMD并运行以下命令:ipconfig /release和ipconfig /renew。第一个命令(ipconfig /release)强制您的网络适配器删除其分配的 IP 地址,第二个命令(ipconfig /renew)更新网络适配器的IP 地址(IP address)。
请注意,您还可以通过键入"ipconfig /release & ipconfig /renew,"CMD在一行中运行这两个命令,而不使用倒引号。如果您像这样键入它们,命令提示符(Command Prompt)会执行第一个命令,完成后,它会自动运行第二个命令。酷(Cool),对吧?🙂
release和renew参数在使用DHCP(动态主机配置协议)(DHCP (Dynamic Host Configuration Protocol))自动分配 IP 地址的网络中很有用。您的系统放弃其当前地址并向DHCP服务器请求一个新地址,这可以帮助您解决某些网络问题(troubleshoot certain network issues)。
5. 如何获取网络适配器MAC(MAC)地址的 nic 信息
获取网络适配器的MAC地址的最快和最简单的方法之一是使用getmac命令。在Command Prompt中,键入getmac并按Enter,如下图所示。
6. 如何使用CMD查看连接到我的网络的计算机和设备?
在某些情况下,您可能希望查看哪些计算机和设备与您连接到同一网络。一种简单友好的方法是使用net view命令。启动命令提示符(Command Prompt)并运行net view。一段时间后,您应该会看到网络中的计算机和设备列表。
但是,关于这个命令有一个警告。网络视图(Net view)不会显示与您在同一网络中的所有计算机和设备。(all)尽管它在专用网络(private networks)上运行良好,但它无法识别智能手机或打印机等设备,并且运行不同操作系统的计算机也存在问题。如果您想清楚地了解连接到网络的所有内容,还应该检查下一个命令。
7. 如何使用CMD查看连接到我网络的所有设备?
查找与您连接到同一网络的所有设备的最佳方法是使用arp命令。打开命令提示符(Command Prompt)并运行arp -a。首先显示的 IP 地址在Interface(Interface)旁边,显示您的网络适配器的 IP 地址。然后,有一个 IP 地址和MAC地址列表(物理地址(Physical Addresses))。所有以与您的网络适配器相同的数字开头的 IP 地址都与您位于同一网络和/或子网中。它们都是连接到您的网络的设备。
接下来的不是真实设备,而是用于多播(multicasting)的 IP 地址。它们通常被您的真实设备用于网络上的流媒体。在我们的示例中,与我们的计算机连接到同一网络的设备都是 IP 地址以 192.168.50 开头的设备。
如果您想以更人性化的方式查看这些设备是什么,请复制它们的MAC地址并使用Google或在允许您检查哪些供应商分配特定MAC地址的网站(例如DNS Checker )上查找它们。例如,如果您正在寻找MAC地址 04-d9-f5-b5-b1-f0,您会发现它是ASUS制造的设备。事实上,它是华硕 ZenWiFi 路由器(ASUS ZenWiFi router)。
8.如何检查您的计算机的网络连接和打开的端口
您可以从netstat(netstat)命令获取其他有用的 cmd nic 信息,该命令可让您查看系统与网络或 Internet 上的任何其他系统之间处于活动状态的网络连接。
如果将-a参数添加到netstat命令,则可以获取包含所有连接和侦听端口的列表,如下图所示。
就是这样!
您知道获取 cmd nic 信息的其他有用方法吗?
当您需要查找有关连接到网络的设备的信息或想要测试网络连接状态时,可以在命令提示符(Command Prompt)中运行的网络命令非常有用。当您遇到网络问题并且您尝试自己解决问题时,它们也很方便。如果您对这些网络命令有疑问、需要帮助或希望我们将其他人添加到列表中,请在下方给我们留言。
Command Prompt (CMD) - 8 network commands you should know
Command Prompt proved itself to be one of the best tools for running basic commands that allow you to work with files and folders from Windows. However, the Command Prompt is much more powerful than just that. You can take things to the next level by running more than just a few advanced commands, including a range of handy network commands. Today, we're going to learn how to use Command Prompt to check the internet connection, the network connections, view information about network devices, and watch connections between your PC and other devices. Without further ado, let's begin:
NOTE: We wrote this guide using Windows 10 with November 2019 Update. However, all the commands illustrated work the same way in Windows 8.1 and Windows 7. Before going any further, if you don't know how to open the Command Prompt, read: 11 ways to launch the Command Prompt in Windows.
1. How to check internet connection in CMD
To check whether your internet connection works, you can use Command Prompt to test your connection to a certain website or internet location. To do that, you can use the ping network command, followed by a web address or IP address. For instance, you can check the connectivity to Digital Citizen without opening a web browser, by typing the command "ping www.digitalcitizen.life." Then press Enter on your keyboard.
If the ping statistics don't show any loss of packets, your internet connection is working as it should. However, if you get lost packets, that means that either your internet connection is broken, or that the website you pinged is not online. To double-check your internet connection, ping at least another website, preferably one that it's always on, such as www.google.com.
The ping command also allows you to use the handy "-t" parameter, which enables you to ping the specified address forever until it's manually stopped. For instance, we typed "ping -t www.digitalcitizen.life." After some time, we wanted to see some connection statistics and we used the keyboard combination "CTRL + Break." This shows the averages of the ping commands run until then.
Finally, we terminated the command by using the keyboard combination "CTRL + C." This stops the endless cycle of ping commands to the specified address.
2. How can I see all the network adapters on my computer using CMD?
To obtain detailed information about your network adapters and connections, use the ipconfig command. Open Command Prompt, type ipconfig, and press Enter. As you can see in the screenshot below, when you run this command, Windows displays the list of all the active network devices, whether they're connected or disconnected, and their IP addresses. You also get details such as their default gateway IP addresses, subnet masks and the state of each network adapter.
If you add the /all switch to the ipconfig command, you can get to a whole new level of detail: DNS information, the MAC (Media Access Control) (in the Physical Address field), and other information about each network component. Check out the picture below to see a sample of what you get from the "ipconfig /all" command.
3. How to check your network connection in CMD
If you want to check whether your network connection to the router is operating as it should, you can use a combination of the commands ipconfig and ping. First, get some cmd nic info about your adapter. In other words, open Command Prompt and run ipconfig. In the list of results, identify the network adapter that's used for connecting to the network you want to test. Then, in its details, find the IP address of your router and note it down. For example, if we'd want to check our Ethernet network connection, we'd run ipconfig and see that our router's IP address is 192.168.50.1.
The next step is to check that the network connection between the router and the computer is OK. To do that, it's enough to run the ping command on the router's IP address. In our example, that would mean that we have to run this command in CMD: ping 192.168.50.1.
If there are no packets lost, then the network connection tested is running well. Otherwise, there's a problem somewhere between your computer and the router, in which case you should check that your PC's network adapter is configured correctly, that the Ethernet cable is OK (if you're using a wired connection), and that the router is configured properly.
4. How to renew the IP address of your network adapter
When your network connection doesn't work as it should, your network adapter might not have the right IP address assigned. A quick way of trying to solve this issue is to renew its IP address and, fortunately, you can do that quickly, straight from the Command Prompt. Open CMD and run the following commands: ipconfig /release and ipconfig /renew. The first one (ipconfig /release) forces your network adapter to drop its assigned IP address, and the second command (ipconfig /renew) renews the network adapter's IP address.
Note that you can also instruct CMD to run both commands in one line by typing "ipconfig /release & ipconfig /renew," without the inverted quotation marks. If you type them like this, Command Prompt executes the first command and, when it's done, it automatically runs the second one. Cool, right? 🙂
The release and renew parameters are useful in networks that use DHCP (Dynamic Host Configuration Protocol) to distribute IP addresses automatically. Your system gives up its current address and requests a new one from the DHCP server, and that can help you troubleshoot certain network issues.
5. How to get nic info about your network adapter's MAC addresses
One of the fastest and easiest ways to obtain the MAC addresses of your network adapters is to use the getmac command. In Command Prompt, type getmac and press Enter, as seen in the image below.
6. How can I see the computers and devices connected to my network using CMD?
In some cases, you might want to see what computers and devices are connected to the same network as you are. One of the easy and friendly ways to do that is to use the net view command. Launch Command Prompt and run net view. After a while, you should see a list of the computers and devices in your network.
However, there's a caveat about this command. Net view doesn't show all the computers and devices that are in the same network as you. Although it works well enough for private networks, it fails to identify devices such as smartphones or printers, and also has issues with computers that are running different operating systems. If you want to get a clear view of everything that's connected to your network, you should also check the next command.
7. How can I see all the devices connected to my network using CMD?
The best way to find all the devices connected to the same network as you is based on using the arp command. Open Command Prompt and run arp -a. The IP address shown first, next to Interface, displays your network adapter's IP address. Then, there's a list of IP addresses and MAC addresses (Physical Addresses). All the IP addresses that start with the same numbers as your network adapter are in the same network and/or subnet as you are. They are all devices connected to your network.
The next ones are not real devices, but IP addresses used for multicasting. They are commonly used by your real devices for streaming media on your network. In our example, the devices connected to the same network as our computer are all the ones that have IP addresses starting with 192.168.50.
If you want to see what those devices are, in a more human-friendly way, copy their MAC addresses and look them up on the internet using Google or on websites that let you check which vendors assign certain MAC addresses, such as DNS Checker. For instance, if you're looking for the MAC address 04-d9-f5-b5-b1-f0, you find that it's a device made by ASUS. In truth, it's an ASUS ZenWiFi router.
8. How to check your computer's network connections and open ports
You can get other useful cmd nic info from the netstat command, which lets you see the network connections that are active between your system and any other systems on your network or the internet.
If you add the -a parameter to the netstat command, you can get a list with all the connections and listening ports, as seen in the image below.
That's it!
Do you know other useful ways to get cmd nic info?
The networking commands that you can run in the Command Prompt can be useful when you need to find information about devices connected to your network or when you want to test your network connections state. They're convenient also when you have networking issues, and you're trying to troubleshoot them by yourself. If you have questions about these networking commands, if you need help, or if you want us to add others to the list, leave us a comment below.