Cool things you can do with this all-purpose networking tool
During the development of Windows NT 5.0— which later became Windows 2000—Microsoft worked briefly with Cisco Systems to try to incorporate some of that company's ideas into the new OS and to help Cisco incorporate some NT 5.0 ideology into Cisco's products. (You can see evidence of the effort today in the Cisco Voice over IP solution, which requires an Active Directory—AD—implementation.) That fleeting flirtation ultimately cooled, but it left behind a framework for Netsh, an extremely useful commandline networking tool.
Even if you have a command-line phobia, you won't be able to resist Netsh, which lets you use the command line or a batch file to perform such tasks as configuring your IP stack settings, setting up a DHCP server from scratch, controlling Windows Firewall, and creating complex and powerful IPsec rules. And Netsh is the only tool I know of that lets you fix a common but frightening side effect of running some anti-spyware applications: completely disabling your IP stack.
Regular readers already know how to use Netsh to configure an IP stack. In "Quick, Automated AD Setup," December 2003, InstantDoc ID 40719, I showed you how to use Netsh to set up an IP address, default gateway, subnet mask, DNS server, and WINS server—all from the command line. Now, I want to show you a few excellent Netsh tricks.
Have you ever moved your laptop from one place to another (e.g., from work to home, from one WAP to another WAP, from wireless to wired Ethernet), and found that the laptop won't change its IP address? For some reason, the computer has formed an emotional attachment to the old IP address, and because the old address isn't worth squat in the new location, you can't even accomplish a successful ping. In such a case, the Netsh command
netsh int ip reset C:\iplog.txtis extremely helpful. I refer to this command as the IP phoenix command because it tears down the IP stack and quickly rebuilds it. C:\iplog.txt is the name of a text file that Netsh will use to report its actions. (For some reason, the logging isn't optional: You must specify the name of a file so that Netsh can write out a log.)
You think that's cool? One of the first things I do when I sit down to troubleshoot someone's system is run a Netsh command that no one seems to know about. Typing
netsh diag guibrings up an HTML page that gives you a hyperlink with which to scan your system. When you click the link, you get a report—arranged in a nice, hierarchical layout—that details every adapter on your system. The command then pings each adapter, along with its associated DHCP servers, its WINS servers, its default gateways, your Microsoft Outlook Express settings, your system's server roles, and so on. Finally, it summarizes the results on a nice, attractive Web page.
Netsh accomplishes much more than I can mention on one page. But I hear you saying, Hey, what was that you said about spyware? Spyware often works by insinuating itself into your Winsock Catalog—essentially, the interface between your applications and the Internet. Spyware likes to settle in there so that it can, well, spy on you. Some anti-spyware tools can find and remove such spyware, but in the process they can end up completely disabling your Windows TCP/IP stack. That's an effective way to protect you from spyware, but it can be the equivalent of destroying the village to save the village.
Fortunately, Netsh can help. Simply type
netsh winsock resetand press Enter. Now, just restart your system. You might need to follow that up with the Netsh IP Reset command, but in a flash you'll have your IP stack back.