cmd command netsh basic tutorial

Source: Internet
Author: User
Tags configuration settings

1. Backup and recovery of network settings
Backup operation: Netsh dump >bak12.txt
Restore operation: Nesh exec Bak12.txt


2, with the command to change the IP, as follows:
C:/>netsh (enter setup mode)
Netsh>interface
Interface>ip
Interface Ip>set Address "Local Area Connection" Static 10.1.1.111 255.255.255.0 10.1.1.254
Interface Ip>exit


C:/>ipconfig (change and then use the ipconfig command to check to see if the change was successful)
Windows $ IP Configuration
Ethernet Adapter Local Connection:
Connection-specific DNS Suffix. :
IP address. ...........:10.1.1.111
Subnet Mask ........... : 255.255.255.0
Default Gateway ..... . : 10.1.1.254


3. Take a look at the netsh command at a glance (netsh mode input? Then enter, such as Netsh>?)

.. -Move to the previous level of the context level.
? -Displays a list of commands.
AAAA-Changes to the ' aaaa ' context.
Abort-discards the changes made in offline mode.
Add-Adds a configuration item to the list of items.
Alias-Add an alias
Bye-Exit the program.
Commit-commits the changes made in the offline mode.
Delete-Deletes a configuration item on the project list.
DHCP-Changes to the ' DHCP ' context.
Dump-Displays a configuration script.
exec-Runs a script file.
Exit-Exits the program.
Help-Displays a list of commands.
interface-Changes to the ' interface ' context.
Offline-Sets the current mode to offline.
Online-Sets the current mode to online.
POPD-Opens a context from the stack.
PUSHD-pushes the current context into the stack.
Quit-Quit the program.
Ras-Changes to the ' RAS ' context.
Routing-Changes to the ' routing ' context.
Set-Updates the configuration settings.
Show-Display information
Unalias-Deletes an alias.
WINS-Changes to the ' wins ' context.


4. Example 1: Switch different fixed IP at any time
Open Notepad, create a new file, and enter the following code in it:
netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1, click File | Save, enter "Home.cmd" in the open window (double quotation marks in the code must be entered) and save it on the desktop.
Similarly, create a office.cmd file in which to enter: netsh interface ip set address "Local Area Connection" static 192.168.1.11 255.255.248.0 192.168.0.1 1, save it as " Office.cmd "file. Later at home just double-click "Home.cmd" to quickly switch the IP address to 192.168.0.10, the subnet mask is 255.255.255.0, the gateway is 192.168.0.1, and the company then double-click "Office.cmd" The IP can be switched to 192.168.1.11, the subnet mask is 255.255.248.0, and the gateway is 192.168.1.1.


A few notes:
1. The IP address assigned by each company is different, the reader can set it by itself or ask the network management.
2. The "Local Area Connection" in the above command is the name of the NIC connection, you can double-click the Network connection icon in the Control Panel to see the name of the corresponding network card. If you have multiple NICs, simply modify the name of the "local connection" above and the IP, subnet mask, and gateway.
3. The last 1 of the above command is the set metric, the value is more professional, the user can be set to 1, regardless.


5. Example 2: Fixed/dynamic IP switching at any time
Create a Static.cmd file on the desktop and enter the appropriate code in it, such as the netsh interface ip set address "Local Area Connection" static 192.168.0.12 255.255.255.0 192.168.0.1 1, also create a dhcp.cmd file, where the following code is entered:


netsh interface ip set address "Local Area Connection" DHCP
Ipconfig/release
Ipconfig/renew


Double-clicking Static.cmd on the desktop later modifies the IP of the local area connection to 192.168.0.12, the subnet mask is 255.255.255.0, the gateway is 192.168.0.1, and double-clicking the dhcp.cmd file causes the local Area connection is set to dynamic IP immediately and the IP address is updated immediately from the DHCP server.

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.