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=192.168.1.10 mask=255.255.255.0 gateway=192.168.1.1 Netsh interface ipv4 set dnsserver "Local Area Connection" source=static address=192.168.1.2 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 anycast Netsh interface ipv6 set dnsserver "Local Area Connection" source=static address=2001:db8: 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 ?
In this tutorial:
- Configuring Windows Networking
- Usability Improvements
- Network And Sharing Center
- Network Explorer
- How Windows Finds Network Resources
- How Windows Publishes Network Resources
- How Windows Creates the Network Map
- Network Map
- Set Up A Connection Or Network Wizard
- Manageability Improvements
- Network Location Types
- Policy-Based QoS
- Selecting DSCP Values
- Planning Traffic Throttling
- Configuring QoS Policies
- Configuring System-Wide QoS Settings
- Configuring Advanced QoS Settings
- Testing QoS
- Windows Firewall and IPsec
- Windows Connect Now in Windows 7
- Core Networking Improvements
- Networking BranchCache
- How Hosted Cache Works
- How Distributed Cache Works
- Configuring BranchCache
- BranchCache Protocols
- File Sharing Using SMB
- Web Browsing with HTTP (Including HTTPS)
- DNSsec
- GreenIT
- Efficient Networking
- What Causes Latency, How to Measure It, and How to Control It
- TCP Receive Window Scaling
- Scalable Networking
- Improved Reliability
- IPv6 Support
- 802.1X Network Authentication
- Server Message Block (SMB) 2.0
- Strong Host Model
- Wireless Networking
- Improved APIs
- Network Awareness
- Improved Peer Networking
- Services Used by Peer-to-Peer Networking
- Managing Peer-to-Peer Networking
- Peer-to-Peer Name Resolution
- EAP Host Architecture
- Layered Service Provider (LSP)
- Windows Sockets Direct Path for System Area Networks
- How to Configure Wireless Settings
- Configuring Wireless Settings Manually
- Using Group Policy to Configure Wireless Settings
- How to Configure TCP/IP
- DHCP
- Configuring IP Addresses Manually
- Command Line and Scripts
- How to Connect to AD DS Domains
- How to Connect to a Domain When 802.1X Authentication Is Not Enabled
- How to Connect to a Domain When 802.1X Authentication Is Enabled