Troubleshooting Network Connections with netsh, netstat, and ipconfig
Posted by raxsoMay 27
netsh is a wide-ranging command-line diagnostic tool that has an exceedingly large number of commands available. The most useful of the netsh commands are the netsh diag commands. Use them to find out information about your PC’s network setup, such as finding the IP address of its mail server, newsgroup server, DNS server, and similar resources.
There are two ways to use netsh: directly from the command line with all its switches, or first getting to the netsh console by typing netsh at the command line and then typing the command from the netsh> prompt that appears. For example, you could type netsh diag show adapter at the command line, which lists every network adapter on your PC, or you could get to the netsh> prompt and type diag show adapter.
Use the netsh command to connect to the resources and then get information about them. For example, to find out the IP address of your DNS servers, type netsh diag show dns; to find out the IP address of your mail server,
type netsh diag connect mail
Useful netsh diag commands
connect ieproxy - Establishes a connection to Internet Explorer’s proxy server, if one exists.
connect mail - Establishes a connection to the default Outlook Express mail server.
ping adapter - Establishes a connection with the named adapter.
ping dhcp - Establishes a connection with a DHCP server.
show adapter - Lists all the adapters on the PC.
show all - Lists all the network objects defined for the local PC, such as adapters, network clients, servers, modems, and other objects.
show dns - Lists all the DNS servers for the specified adapter.
show gateway - Lists all the gateways for the specified adapter.
netstat is a command line tool to get information about open network connections. If you want to get a snapshot of all incoming and outgoing network connections, use the netstat command. At a command prompt, type netstat. It lists all connections, including the protocol being used, the local and Internet addresses, and the current state of the connection.
It will help you know whether connections are live, the network or Internet device to which they’re connected, and which local resource is making the connection. It’s best suited for when you’re troubleshooting network problems and want to find out whether certain ports are open, why certain computers on the network are having connection problems, and similar issues.
Netstat switches:
-a - Displays all open connections and ports.
-e - Displays Ethernet statistics about packets transmitted and received. Can be combined with the -s switch.
-n - Displays the addresses and ports in numeric, IP address form.
-o - Displays the process identifier (PID) that owns each connection.
-p proto - Displays the connections used by the protocol, which can be IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
-r - Displays the network’s routing table.
-s - Displays statistics for each protocol. It lists all statistics for all protocols, but you can list only those for a specified protocol if you combine it with the -p switch.
interval value - Run netstat repeatedly, pausing value seconds between each new display. To stop the display, press Ctrl-C.
IPConfig One of the most powerful tools for analyzing and troubleshooting TCP/IP problems is the ipconfig command-line utility. It provides information about each of your adapters, including the assigned IP address, subnet mask, default gateway, MAC address, DNS servers, whether DHCP is enabled, and a variety of other data.
ipconfig provides basic information about your IP address, subnet mask, default gateway, and a connection-specific DNS suffix, if any. However, you can get much more detailed information by using the /all switch, like this: ipconfig /all. For most troubleshooting purposes, use the /all switch.
You can also use ipconfig to release and renew IP addresses, and perform other troubleshooting functions as well. For example, to renew an adapter’s IP address, use this command:
ipconfig /renew “adapter name”
where adapter name is the name of the adapter whose IP address you want to renew. Make sure to put quotes around the adapter name and use spaces if there is more than one word in the adapter name.
Switches:
/all - Displays complete TCP/IP configuration information.
/displaydns - Displays information from the DNS resolver cache
/flushdns - Clears the DNS resolver cache
/registerdns - Refreshes all DHCP leases and reregisters DNS names.
/release “adapter” - Released the IP address for the specified adapter.
/renew “adapter” - Renews the IP address for the specified adapter.
/setclassid “adapter” newclassid - Resets the DHCP Class ID for the specified adapter.
/showclassid “adapter” - Displays the DHCP Class ID for the specified adapter.
Like this blog? Why not buy me a cup of coffee?




![[hackers black book]](http://raxso.net/images/hbb-ani-misuse.gif)





Leave a Reply