Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 06, 2009

Network Configuration Tasks with Netsh

Simple commands to manage Windows Firewall, network adapters, and other system configurations
RSS
Subscribe to Windows IT Pro | See More Dynamic Host Configuration Protocol (DHCP) Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Netsh is a powerful and indispensible command-line tool for updating Windows network configuration settings. However, the variety of options available with Netsh can make it confusing to work with. In this column, I'll show you ten ready-to-use examples of Netsh commands for some of the most widely used network functions. For more information about Netsh, you can download "Windows Server 2008 Network Shell (Netsh) Technical Reference" from the Microsoft Download Center.

10. Show the system's current IP configuration—You can use the following command to see if the system is using DHCP or static addressing as well as to show the system's current IP address, submask, gateway address, and DNS server:

netsh interface ip show config 

9. Configure a remote system—One of the best features of the Netsh command is its ability to work with remote systems as easily as it can local systems. The set machine command changes the computer that the Netsh command operates on to a different system on the network. For this command to work, you need to be logged on with an account that has administrative rights on the remote system:

netsh set machine win2008-2 

8. Working with IPv6—Netsh commands work with both Windows IPv4 and IPv6 network stacks. To display your system's IPv6 address, use the following Netsh command:

netsh interface ipv6 show address 

7. Enable and disable Windows Firewall—Netsh can work with the built-in Windows Firewall. With the release of Windows Server 2008, the older Netsh firewall commands have been deprecated and replaced by the advfirewall commands. The following commands show how to disable then re-enable the Windows Firewall:

netsh advfirewall set currentprofile state off
netsh advfirewall set currentprofile state on

6. Open a firewall port—You can also use Netsh to open ports in the firewall for various applications. The following example shows how to open TCP port 1434 for Microsoft SQL Server access:

netsh advfirewall firewall
  add rule name="SQL Server"
  dir=in action=allow
  protocol=TCP localport=1434

5. Display network adapters and their status—Many of the Netsh configuration commands require you to supply the name of the interface that you want to configure. The default value is usually Local Area Connection, but many administrators and users change this value. To find the name of the system's network adapters or a system's wireless network adapters, use the following commands:

netsh interface show interface
netsh wlan show interface

4. Configure a network adapter to use a static IP address—The following example shows how you use Netsh to set the IP address of the network adapter named Local Area Connection to 192.168.0.100, the subnet mask to 255.255.255.0, and the gateway address to 192.168.0.254:

netsh interface ip
  set address "Local Area Connection"
  static 192.168.0.100
  255.255.255.0 192.168.0.254 1

3. Configure a network adapter with the address of a DNS server—When you change the system's IP address type to static, you typically need to change the DNS configuration as well. This example shows how you use Netsh to configure the Local Area Connection to use a DNS server with the address 192.168.0.2:

netsh interface ip
  set dns "Local Area Connection"
  static 192.168.0.2

2. Add a second DNS server to a network adapter's configuration—Many networks use multiple DNS servers. To add a secondary DNS server with the address 192.168.0.3, use the following command:

netsh interface ip
  add dnsserver "Local Area Connection"
  192.168.0.3

1. Set a network adapter to use a DHCP-assigned IP address—You can also use Netsh to set your system's network adapter to use a DHCP server for its IP address and to dynamically obtain the address of your network's DNS servers. The following Netsh command configures your network adapter to use DHCP and DNS:

netsh interface ip
set dns "Local Area Connection" dhcp

End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Is Microsoft Just Like IBM?

Microsoft has defined the way we do business from a technology perspective for years. But with a younger generation that lives in the clouds, is Microsoft's recent progress in cloud computing too little, too late? ...

Microsoft, News Corp. Discuss Locking Out Google

Microsoft and Rupert Murdoch's News Corp. recently discussed an alliance that would counter Google's fledgling online news service. ...


Related Articles Use Netsh to Easily Change IP Addresses

Netsh Tricks

Avoid Risky Rules With Netsh

Cool Things to Do with Netsh

Task Automation Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Managing IT Across Multiple Locations

Cutting Costs with Client Management

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement