Typical applications of Netsh commands in Windows

Source: Internet
Author: User

The netsh command has been released for a long time. It is included in Windows 2000, XP, and 2003. Windows Server 2008 only extends the parameters of netsh. In daily work, many administrators do not know much about netsh, or even what functions netsh has enhanced in Windows Server 2008. By reading this article, the Windows administrator can find the answers to the questions listed above.

1. What is Netsh?

Netsh of Microsoft Windows is a command line script utility. Use the netsh tool to view or change the network configurations of a local or remote computer.

Not only can these commands be run on a local computer, but also on a remote computer on the network.

You can manually run the Netsh command or create a batch file or script to automate the process. Netsh provides the script function, allowing you to run a group of commands for a specified computer in batch mode. With netsh, you can save the configuration script as a text file for archiving or configuring other computers.

Ii. Comparison between Windows Server 2008 netsh and Windows XP netsh

Even at the Core Command level, there are some differences between netsh of Windows XP and netsh of Windows Server 2008. To compare these, we can run "netsh/?" In each operating system /?". Although Windows XP has more "routing" options than Windows Server 2008, Windows Server 2008 has more content than the netsh option under windows XP, as shown below:

* Dhcp

* Dhcpclient

* Http

* Ipsec

* Lan

* Nap

* Netio

* Rpc

* Winhttp

From the list above, we can see that there are more options in Windows Server 2008.

Iii. Top 10 netsh commands frequently used by administrators

Next, let's begin to introduce some netsh commands commonly used by system administrators.

#10-how to get help information

Every Windows administrator should know how to obtain netsh help information. This is actually very easy-just use "/?" . For example, to display all the netsh content (option type), you only need to enter netsh /?, 1:

 

* ** Figure 1: netsh /? Execution result of help options

In, you can select a context and use the configuration items in the context to guide the next operation. For example, enter netsh lan /? , You can see the interface shown in 2:

 

* ** Figure 2: netsh lan /? Execution result

From the information shown above, you can continue to guide us to continue:

Netsh lan show /?

To display the NIC information, run the following command:

Netsh lan show interfaces

Use /? The netsh command can guide the use of many netsh commands to ultimately achieve our operation goals.

#9-Support for remote computer names and logon creden

The netsh Command Execution parameters support remote computer names, IP addresses, and password creden. "-R" indicates the machine name, "-U" indicates the user name, and "-p" indicates the password.

Here is an example:

Netsh-r WinXP-1-u winxp-1administrator-p My! Pass1 interface ip show config

This example provides the remote computer name, remote user name, and password to remotely execute commands over the network. As long as the remote computer supports this command (different operating systems will use different commands), it can be executed.

#8-run in interactive or Script Mode

The netsh command can be run interactively, manually entered, or in a script. If you want to manually enter commands on a local machine or remote machine, you only need to enter netsh in the command line and you will see the following interface:

Netsh>

At the netsh> prompt, you can enter all the netsh commands you want to call, or even tell netsh to connect to a remote computer.

On the other hand, you can use netsh-f to specify the script name used by netsh.

#7-open the firewall port

The netsh command can quickly and conveniently open a firewall port. In the following example, port 445 is Enabled:

Netsh firewall set portopening tcp 445 smb enable

If the command is successfully executed, the Response Message "OK." is displayed.

#6-import and export the current network configuration

The netsh command can easily Import and Export your IP address configurations. Unlike the operations on the GUI, to export configuration information, enter the following command:

Netsh-c interface dump> test.txt

 

* ** Figure 3: Export and view IP address configurations

Run the following command to import the configuration file later on the same computer or on different machines:

Netsh-f test.txt

#5-try the latest use of the Netsh command

Many new features in Windows Server 2008 involve the netsh command. The following are the new types of netsh commands in Windows Server 2008:

* Dhcp

* Dhcpclient

* Http

* Ipsec

* Lan

* Nap

* Netio

* Rpc

* Winhttp

We can not only set the DHCP client, but also set the DHCP server. You can also configure IPSec encryption and network access protection (NAP) clients ......

When some roles are added to the server, more contexts are displayed. For example, if you add a role for the network policy Server in Windows Server 2008, the context of the netsh configuration item will have an additional "nps ".

#4-TCP/IP troubleshooting and nic repair

With netsh, You Can troubleshoot and reset the TCP/IP Nic. Let's look at the following examples:

* Reset the configuration information of all IP protocol stacks and output the log file netsh int ipv4 reset resetlog.txt

* Install TCP/IP protocol -- netsh int ipv4 install

* Uninstall the TCP/IP protocol -- netsh int ipv4 uninstall

#3-configure windows Advanced Firewall

In Windows Server 2008 and Windows Vista, you can use the new advfirewall network settings to configure a two-way Windows advanced firewall. Of course, you can also set it to a traditional Windows Firewall. The following are some examples:

* Display all firewall rules -- netsh advfirewall firewall show rule name = all

* Delete all advanced firewall rules related to port 21-netsh advfirewall firewall delete name rule name = all protocol = tcp localport = 21

* Export the Windows advanced firewall settings -- netsh advfirewall export "c: advfirewall. wfw"

Perhaps the most frequently used command is to enable or disable Windows Firewall. You can use the following command:

Netsh firewall set opmode disable or:

Netsh firewall set opmode enable

#2-configure Wireless Settings

In Windows Server 2008 and Windows Vista, you can use the netsh wlan command to configure the wireless network configuration file and connect it to the wireless network. Here are several examples:

* Connect to a defined wireless network-netsh wlan connect ssid = "mySSID" name = "WLAN-Profil1"

* View the current wireless settings -- netsh wlan show settings

* Add a configuration file for Wireless networks -- netsh wlan add profile filename = "Wireless Network Connection-BOW.xml"

#1-configure IP addresses and network settings

Just as netsh stands for network shell, netsh initially aims to configure basic network parameters. Here are some examples:

* View the ip address of the NIC-netsh interface ip show config

* Set the ip address of the NIC to use DHCP -- netsh interface ip set address name = "Local Area Connection" source = dhcp

* Set the ip address of the NIC to use a static ip address-netsh interface ip set address "Local Area connection" static 10.0.0.9 255.0.0.0 10.0.0.1 1

* Add DNS server settings-netsh interface ip add dnsserver "Local Area Connection" 10.0.0.1

Iv. Summary

Netsh command line utility has always been a very powerful tool for Windows system administrators. In Windows Server 2008 and Windows Vista, as new features increase, netsh is more powerful and powerful.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.