Batch processing to quickly switch IP addresses, gateways, and DNS

Source: Internet
Author: User

D:/>netsh
Netsh>ip
Netsh>interface
Netsh interface>ip
Commands in this context:
Set address-Sets the IP or default gateway for the specified interface.
Set DNS-sets the DNS server mode and address.
Set wins-sets the WINS server mode and address.
netsh interface ip>set address

Usage: Set address [name=]
[[Source=]dhcp |
[source=] static [ADDR=]IP address [mask=]ip Subnet mask]
[[Gateway=]|none [Gwmetric=]integer]

Parameters:
Tagged value
Name-Interface names.
Source-One of the following values:
DHCP: For the specified interface, set the IP address configured with DHCP.
Static: Sets the IP address to be set using a local static configuration.
Gateway-One of the following values:
: The specified default gateway for the IP address you set.
None: Default gateway is not set.
Gwmetric-Metric for the default gateway. If the gateway is set to ' None ', this field should not be set.
The following options are set only when ' source ' is ' static ':
Addr-Specifies the IP address of the interface.
Mask-Specifies the subnet mask for the IP address.

Example: Set address name= "Local area Connection" Source=dhcp
Set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1

The above is a step-by-step entry with Netsh, in fact, you can use a command directly in DOS to modify the IP address, such as:
Netsh interface IP set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
Note: The above parameters can not be omitted, the gateway does not have to write none, there is a gateway is the metric is usually written 1.

Home Ip.bat
Program code netsh interface ip delete DNS "Local Area Connection" Addr=all
netsh interface ip set address name= "Local Area Connection" Source=dhcp
Ipconfig/flushdns



Company Ip.bat
Program code
netsh interface ip delete DNS "Local Area Connection" Addr=all
netsh interface ip add DNS "Local Area Connection" addr=202.119.230.8
netsh interface ip add DNS "Local Area Connection" addr=202.106.196.115 netsh interface ip add address "Local Area Connection" 192.168.0.8 255.255.255.0
netsh interface ip add address "Local Area Connection" gateway=192.168.0.1 gwmetric=1
Ipconfig/flushdns

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.