Windows 7 / Networking

Command Line and Scripts

You can also configure network settings from the command line or from a script using the Netsh tool and commands in the Netsh interface ipv4 or Netsh interface ipv6 contexts.

For example, to configure the standard network interface to use DHCP and to use the DNS servers provided by DHCP, you could issue the following commands.

Netsh interface ipv4 set address "Local Area Connection" dhcp
Netsh interface ipv4 set dnsserver "Local Area Connection" dhcp

Note Windows XP also included the Netsh tool. However, the Windows XP version of Netsh uses different commands. For example, you would use Netsh interface ip set dns to configure DNS settings for a computer running Windows XP instead of Netsh interface ipv4 set dnsserver, which you use to configure DNS settings for a computer running Windows Vista or Windows 7. However, Netsh in Windows Vista and Windows 7 is backward compatible and will accept the older, Windows XP-compatible syntax.

Because DHCP is the default setting for network adapters, it is more likely that you will need to use Netsh commands to configure a static IP address. The following command demonstrates how to do this for IPv4.

Netsh interface ipv4 set address "Local Area Connection" source=static
address= mask= gateway=
Netsh interface ipv4 set dnsserver "Local Area Connection" source=static
address= register=primary

The following commands demonstrate configuring a static IP address and DNS server configuration for IPv6.

Netsh interface ipv6 set address "Local Area Connection" address=2001:db8:3fa8:102a::2
Netsh interface ipv6 set dnsserver "Local Area Connection" source=static
3fa8:1719::1 register=primary

You should avoid using scripts to configure production client computers because they are not tolerant of varying hardware configurations and because DHCP provides most of the configuration capabilities required for production networks. However, scripts can be useful for quickly changing the network configuration of computers in lab environments. Instead of manually writing Netsh commands, you can configure a computer using graphical tools and use the Netsh tool to generate a configuration script.

Note You can generate a configuration script that can be run from within Netsh by running the command Netsh interface dump > script_filename. You can then apply that script using the command Netsh -f script_filename.

Netsh provides the ability to configure almost any aspect of Windows 7 networking. For detailed instructions, refer to Windows Help And Support or run the following command from a command prompt.

Netsh ?
[Previous] [Contents] [Next]

In this tutorial:

  1. Configuring Windows Networking
  2. Usability Improvements
  3. Network And Sharing Center
  4. Network Explorer
  5. How Windows Finds Network Resources
  6. How Windows Publishes Network Resources
  7. How Windows Creates the Network Map
  8. Network Map
  9. Set Up A Connection Or Network Wizard
  10. Manageability Improvements
  11. Network Location Types
  12. Policy-Based QoS
  13. Selecting DSCP Values
  14. Planning Traffic Throttling
  15. Configuring QoS Policies
  16. Configuring System-Wide QoS Settings
  17. Configuring Advanced QoS Settings
  18. Testing QoS
  19. Windows Firewall and IPsec
  20. Windows Connect Now in Windows 7
  21. Core Networking Improvements
  22. Networking BranchCache
  23. How Hosted Cache Works
  24. How Distributed Cache Works
  25. Configuring BranchCache
  26. BranchCache Protocols
  27. File Sharing Using SMB
  28. Web Browsing with HTTP (Including HTTPS)
  29. DNSsec
  30. GreenIT
  31. Efficient Networking
  32. What Causes Latency, How to Measure It, and How to Control It
  33. TCP Receive Window Scaling
  34. Scalable Networking
  35. Improved Reliability
  36. IPv6 Support
  37. 802.1X Network Authentication
  38. Server Message Block (SMB) 2.0
  39. Strong Host Model
  40. Wireless Networking
  41. Improved APIs
  42. Network Awareness
  43. Improved Peer Networking
  44. Services Used by Peer-to-Peer Networking
  45. Managing Peer-to-Peer Networking
  46. Peer-to-Peer Name Resolution
  47. EAP Host Architecture
  48. Layered Service Provider (LSP)
  49. Windows Sockets Direct Path for System Area Networks
  50. How to Configure Wireless Settings
  51. Configuring Wireless Settings Manually
  52. Using Group Policy to Configure Wireless Settings
  53. How to Configure TCP/IP
  54. DHCP
  55. Configuring IP Addresses Manually
  56. Command Line and Scripts
  57. How to Connect to AD DS Domains
  58. How to Connect to a Domain When 802.1X Authentication Is Not Enabled
  59. How to Connect to a Domain When 802.1X Authentication Is Enabled