Detailed description of configuring IP script bat

Source: Internet
Author: User

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C: \ Documents and Settings \ sdfkjs> ipconfig/all

Windows IP configuration

Host Name ......: My-Tomato
Primary DNS suffix .......:
Node Type ......: Unknown
IP routing enabled...: No
Wins proxy enabled...: No

Ethernet Adapter local connection:

Connection-specific DNS suffix .:
Description ......: via PCI 10/100 MB Fast Ethernet adapt
Er
Physical address ......: 00-30-18-a9-cb-2a
DHCP enabled...
IP address ......: 192.168.30.190
Subnet Mask ......: 255.255.255.0
Default Gateway ......: 192.168.30.1
DNS servers ......: 202.131.80.1
202.131.80.5

C: \ Documents and Settings \ sdfkjs>

 

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C: \ Documents ents and Settings \ yqc> CD \

C: \> ipconfig/All // first view the original IP address and DNS address

Windows IP configuration

Host Name ......: My-Tomato
Primary DNS suffix .......:
Node Type ......: Unknown
IP routing enabled...: No
Wins proxy enabled...: No

Ethernet Adapter local connection:

Connection-specific DNS suffix .:
Description ......: via PCI 10/100 MB Fast Ethernet adapt
Er
Physical address ......: 00-30-18-a9-cb-2a
DHCP enabled...
IP address ......: 192.168.30.190
Subnet Mask ......: 255.255.255.0
Default Gateway ......: 192.168.30.1
DNS servers ......: 202.131.80.1
202.131.80.5

C: \> netsh // The main commands for configuring IP and DNS addresses in windows. They are very powerful. If you are interested, you can find other functions on the Internet.
Netsh> Interface
Netsh interface> ip
Netsh interface IP> set // view how to use the set configuration command

The following commands are valid:

Commands inherit from the netsh context:
Set file-copy the output from the console to a file.
Set machine-sets the current computer to be operated.
Set mode-set the current mode to online or offline.

Commands in this context:
Set address-set the IP address or default gateway of the specified interface.
Set DNS-set the DNS server mode and address.
Set wins-set the WINS server mode and address.
Netsh interface IP> set add // view IP address usage

Usage: Set Address [name =] <string>
[[Source =] DHCP |
[Source =] Static [ADDR =] IP Address [mask =] IP subnet mask]
[[Gateway =] <IP address> | none [gwmetric =] integer]

Parameters:

Tag Value
Name-Interface Name.
Source-one of the following values:
DHCP: for a specified interface, configure IP addresses using DHCP.
Address.
Static: Set the IP address using the local static configuration.
Address.

Gateway-one of the following values:
<IP address>: Specifies the default IP address.
Gateway.
None: do not set the default gateway.
Gwmetric-the number of hops of 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-IP address of the specified interface.
Mask-specifies the subnet mask of the IP address.

Note: It is used to change the IP Address Configuration Mode from DHCP to static or from static.
Change the mode to DHCP. Use static IP addresses to add IP addresses or
Default Gateway.
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

Netsh interface IP> set Add "Local Connection" DHCP // sets the Dynamic Allocation of IP addresses, subnet masks, and default gateways)
OK.

Netsh interface IP> set Add "Local Connection" static 192.168.30.190 255.255.255.0 192.168.30.11
OK. // Set static IP addresses, subnet masks, and default gateways (note the following"1", Otherwise the default gateway cannot be set)

Netsh interface IP> set DNS // view how to configure DNS

Usage: Set DNS [name =] <string> [Source =] DHCP | static [ADDR =] <IP address> | none
[[Register =] None | primary | both]

Parameters:

Flag Value
Name-the name of the interface.
Source-one of the following values:
DHCP: sets DHCP as the source for configuring the DNS server for a certain interface.

Static: Set the source of the DNS server to local static configuration.

ADDR-one of the following values:
<IP address>: an IP address of the DNS server.
None: clears the DNS server list.
Register-one of the following values:
None: Disable Dynamic DNS registration.
Primary: Only registered under the primary DNS suffix.
Both: It is registered under the primary DNS suffix and under the specified connection suffix.

Note: Set the DNS server to DHCP or static mode. Only when the source is "static ",
The "ADDR" option can also be used to configure the IP address of the DNS server for this specific interface.
Address in the case of a static list.

Example:

Set DNS name = "Local Area Connection" Source = DHCP
Set DNS "Local Area Connection" static 10.0.0.1 primary

Netsh interface IP> set DNS "Local Connection" DHCP // you can specify a dynamic dns address.
OK.

Netsh interface IP> set DNS "Local Connection" static 202.131.80.1 // set the static primary DNS address
OK.

Netsh interface IP> Add DNS "Local Connection" 202.131.80.5 // Add a static backup DNS address
OK.

Netsh interface IP> exit // exit

The above Article breaks down the DOS configuration IP and DNS in detail. In fact, the batch processing of BAT configuration IP and DNS is to edit the command in the. BAT file and double-click to run the. Bat program.

For example:

Enter the following IP addresses in notepad and save them as any A. BAT file.

Static IP:

Netsh.exe interface IP Set address "Local Connection" static 192.168.30.190 255.255.255.0 192.168.30.1 1

After you double-click it, you will find that your IP address has been set to static.

Dynamic IP:

Netsh.exe interface IP Set address "Local Connection" DHCP

After you double-click it, you will find that your IP address has been set to dynamic.

Likewise:

The DNS configuration is also saved as any B. BAT file.

Static DNS:

Netsh.exe interface IP Set DNS "Local Connection" static 202.131.80.1 primary

Netsh.exe interface IP add DNS "Local Connection" 202.131.80.5

After you double-click it, you will find that your static DNS also exists.

Dynamic DNS:

Netsh.exe interface IP Set DNS "Local Connection" DHCP

After you double-click to run it, you will find that your DNS becomes dynamic

 

 

@ Echo off
Rem modifies IP addresses, subnet masks, and gateways.
CMD/C netsh interface IP Set address name = "Local Connection" Source = static ADDR = 21.5.251.63 mask = 255.255.0.0 gateway = 21.5.251.254 gwmetric = 1

It seems that this can also be done. You can find the information on the Internet and try it if you are interested!

 

If you still have problems configuring IP addresses and DNS in DOS, please refer to my previous article!

If you have more good things, I hope your friends can provide them. Thank you !!!

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.