Network Management & Troubleshooting Commands - Windows Command Line (CMD)
What We'll Learn:
This short guide is all about various cmd commands you can use to manage and troubleshoot networks.
We are going to learn:
- How to view various information, such as which ports are active or which applications initiate connections.
- How to configure our computers routing table.
- How to view or configure our internet protocol configuration.
- How to view every active network connection in our computer.
- And much more.
Lets get started!
Lets start with something simple.
Ping can help you resolve internet or network connectivity issues, by sending packets to your destination and awaiting a response.
Type ping followed by a URL or an IP address.
If the server is there, you will see the reply as well as the amount of time the interaction took.
Tracert is similar to ping and it can be used to visually identify exactly where a problem occurs when a packet gets sent and received from its destination.
Tracert, as the name implies, traces each hop on the route the packet takes to reach your destination, and tells you information about each of them.
To use it, type tracert followed by your destination URL or IP.
Pathping is a more advanced version of ping as well as a combination of ping and tracert.
Pathping sends ping commands to every hop a packet takes to reach your destination over a period of time.
Resulting in a detailed report. Its usage its similar to both path and tracert, simply type Pathping followed by your destination URL or IP.
The operation can take quite a long time to complete and thus tracert is usually preferred. However, the extra information it provides can be especially useful at times.
Type ipconfig in your command line, to get all sorts of information about your IP configuration and all the IP addresses your pc is currently using.
A particularly useful parameter is /flushdns which will completely delete your dns cache.
You can also use the following commands one after the to assign a new IP address to your computer.
Ipconfig is immensely powerful and if you want to learn more about it check out this blog post where we go in depth into how it works and how it can be used.
Use nslookup to find the IP of a server from a domain name. Simply type nslookup followed by the domain you want to resolve.
Alternatively, you can perform a reverse lookup by entering an IP address and finding out the associated domain name.
Netstat stands for network statistics and as the name suggests it can be used to display various information about your network connections such as which application (if any) is establishing connections, which ports are being used, and various other statistics.
You can use this information to troubleshoot or manage your network as well as its connections.
Typing netstat by itself will display every active connection in your computer along with the protocol, the local and remote address as well as whether the connection is currently active or not.
Once you are done, press control and c to stop the execution of the command.
The output of the netstat command can get a bit messy and confusing, you can use several parameters to filter, sort or display more information about your network connections.
Starting with -a, which will display every active port sorted numerically.
The -e parameter, which will display various information such as the number of packets sent and received the number of errors that have occurred and more.
Finally, we have the -b parameter which requires administrator privileges to be run and will display which application is establishing a connection.
There are many more parameters that can be used along with the netstat utility browse through the output of the help command to find them out.
You can use the route command to display or modify your computer’s routing table. To display your routing table, type route followed by the parameter print.
To modify your routing table, use the following syntax:
route (-p) add/delete/change destination (mask-subnet) gateway (-if interface)
Confused? lets break it down:
The -p parameter makes your entry persistent, without this parameter your entry will be deleted in the next boot.
Next, type the action you want to take with this entry and the IP of the destination subnet, optionally you can enter the subnet mask, if you don’t, the default will be used.
Then, enter the gateway IP and finally with the -if parameter you can specify the interface from which packets will be sent.
Make sure you know what you are doing before changing route tables, the wrong command can potentially break your computer’s connectivity.
The Netsh command can be used to do a variety of things. Everything from viewing your internet protocol configuration to deleting your address resolution protocol configuration cache and configuring various tcp/ip related settings.
Lets start with viewing your interface configuration. To do so simply type the following command.
netsh interface ip show config
Let’s break this command down:
The netsh command works a bit differently than other cmd commands because it doesn’t not accept parameters in the usual sence but rather accepts contexts.
As the name suggests “contexts” are words that provide context to the netsh command so that it knows what to do. In this case the “interface” context tells our command that the operation we want to perform is on our interfaces.
The “ip” command specifies that we want to do something on the internet protocol configuration and finally the “show config” contexts tell our command to show us our configuration.
Apart from simply viewing information we can use the netsh command to perform a number of operations on our network configuration. For example, with the following command we can delete the cache of our address resolution protocol (or arp for short).
netsh interface ip delete arpcache
We can also configure our tcp/ip settings directly from the command line. The following command for example will change the static ip, subnet mask and gateway ip of our “Local Area Connection” interface.
netsh interface ip set address name="Local Area Connection" static 192.168.1.5 255.255.255.255 192.168.1.1
We can even use the Netsh command to manage our firewall. With this command for example we can create an exception for a specific port.
netsh firewall add portopening TCP 1234 MyPort
These are just a few of the things that the Netsh command can do. Browse through the output of the help command or search the internet to find out what else it can be used for.
- Use ping, tracert and pathping to troubleshoot network problems.
- Netstat stands for network statistics and as the name suggests it can be used to display various information about your network connections.
- Use ipconfig and nslookup to get all sorts of information about your network or a server.
- Use the route command to display or configure your computer’s routing table.
- The Netsh command can be used to view or configure your internet protocol configuration.
You now know how to use the command line to manage and troubleshoot a network.
If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows command Line.
Dont Stop learning!
Click the button bellow and start watching our windows command line course!
No more searching or memorizing commands!