
One of the things I use the terminal for on Windows, in both PowerShell and WSL, is for running basic network diagnostics. Here are the commands I use most frequently.
ping
Is that site up or down?
This is a basic networking command. This was the first one that a community college networking class instructor demonstrated in the Command Prompt. This was in the days before PowerShell even existed.
ping is a sends packets to a remote system and waits for it to echo them back. This is useful for determining if a site is down or your network connection has failed.
For example, to ping google:
ping google.com
You can also ping IP addresses:
ping 192.168.0.1
This will send four packets to google. If your connection and the remote site is working, you’ll get some responses.
You’ll also see some other information. You’ll see the round-trip times, the size of the packets in bytes, and the TTL, or “Time To Live.” This number defines the maximum number of hops that a packet can go through before it’s declared “dead.”
You’ll also get some statistics, such as the minimum, maximum, or average ping times. The latter will probably annoy statisticians, but the “average” refers to the mean, as it does among normal people.
You can change the number of replies with the -n option.
A “Request timed out” message does not necessarily mean a host is unresponsive or your network is down. A lot of hosts are set to ignore ping messages for security, on the theory that if you can’t ping a machine, you can’t break into it.
ping (WSL) version
Ping forever in Linux
On Windows, I tend to spend more time in Ubuntu on WSL for command-line use, because there are a lot more programming tools on that side. I can also mix and match the two environments from the same command line. There is also a ping command.
It works almost identically to the Windows version:
ping google.com
There’s a difference in the default behavior between the Windows and Linux versions of ping. While Windows will stop by default after four pings, the Linux ping command will run forever until you stop it by pressing Ctrl + c.
You can make it stop after a certain number of pings by using the -c option:
ping -c 4 google.com
As with the Windows version, the Linux ping will display statistics on the round-trip times. It also includes, the minimum, maximum and average ping times, but also the standard deviation, which will help you determine the spread of the ping times, reported as “mdev.”
If the ping command isn’t found, try installing the iputils-ping package:
sudo apt install iputils-ping
tracert
Trace the path your packets take
Windows also includes a tool to run a traceroute, or a path through the network, from your machine to a remote hostname or IP address. It’s called tracert
Do you remember the TTL? tracert works by setting the TTL to 0 at increments it by 1, listing the node that replied with each packet.
To use it, you can use the tracert command similar to the ping command:
tracert google.com
You’ll see the local nodes from your ISP, through some exchange. A large ISP will have a lot of its own exchange points.
As with ping, a lot of nodes will not report back. This will be represented as blank entries. It’s interesting to see where these packets go. The routes can change through each pass, because internet routers can choose different paths. There’s also a remarkable consistency, because the nodes are pretty good at optimizing themselves these days.
Tracepath
The Linux version of tracert
As with ping, tracert on Windows has a WSL counterpart. It’s called tracepath, and you can install it through apt:
sudo apt install iputils-tracepath
You can also use it similarly to tracert:
tracepath google.com
I find that the Windows tracert command seems to work more reliably, as much as I love Windows and WSL. This might be due to the how it runs as a native program and thus is closer to the networking hardware.
I can call tracert from the Linux side by just appending a “.exe” in WSL
tracert.exe google.com
mtr
Combine a ping and a traceroute in WSL
If you were looking for a command that could combine the features of both a ping and a traceroute, you’re in luck if you use WSL. MTR is a tool that does just that. You can install it in WSL with this command:
sudo apt install mtr
You can use it in the same way as ping or tracert:
mtr google.com
By default, it will display a graphical window with the combined ping and traceroute continually running, but the -t option will make it run in the terminal.
You can set a shell alias to alter its behavior permanently if you want.
Ipconfig
Check your network interfaces
The ip command on Linux lets me examine the status of networking interfaces, but its usefulness is limited in WSL because it’s dealing with virtualized interfaces. The Windows command-line counterpart is ipconfig.
I can just enter the command at the prompt to see all the active adapters.
Netstat
See open connections
Another useful command is netstat, which lets me see all the open network connections.
Just type “netstat” at the PowerShell or Command Prompt. To exit it, press Ctrl + c.
This can be useful in dealing with any security problems. Just run netstat and make sure any open connections are accounted for.
route
Which way to the internet?
Another useful command is route, which displays the routing table:
route print
It would probably be more useful to me if I didn’t have a Wi-Fi with only one internet connection. My packets to and from the outside world can only go through the router and cable modem.
Networking from the Windows command line
With PowerShell and WSL, you can quickly run diagnostics to troubleshoot network problems on Windows. Whether you want to find out if a site is down, or you want to learn more about networking, the Windows command line is a good place to start.








