Modify IP addresses and dns wins under CMD

Source: Internet
Author: User

Source: sakurakio s BLOG

Go to the cmd command line:

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

C: Documents and SettingsAdministrator> netsh
Netsh> interface
Netsh interface> ip
Netsh interface ip> set address local connection static 192.168.1.100 255.255.248.0 192.168.1.1 1

After entering the information, the system prompts "OK "... OK!

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 (note: "1" here must not be omitted)

Netsh interface ip> set address local connection static 192.168.1.100 255.255.248.0 192.168.1.1 1
OK.

Netsh interface ip> dump

#----------------------------------
# Interface IP configuration
#----------------------------------
Pushd interface ip


# "Local Connection" interface IP configuration

Set address name = "Local Connection" source = static addr = 192.168.1.100 mask = 255.255.248.0
Set address name = "Local Connection" gateway = 192.168.1.1 gwmetric = 1
Set dns name = "Local Connection" source = static addr = 202.96.69.38 register = PRIMARY
Add dns name = "Local Connection" addr = 219.150.32.132 index = 2
Set wins name = "Local Connection" source = static addr = none

Popd
# End of interface IP configuration

Netsh interface ip> exit

 

I also found an article:

This was unfortunately lost during the last Database Import. Today, when the injection attack happened, the database machine did not set up a gateway, so add one first, if the problem persists, you can directly access the internet. If the ip address of the gateway is unknown, you have to write a batch for detection.

FOR/L % I in (255, 100) do ping 192.168.1.% I-n 1-w> c: ping.txt

Then, the results of ping.txt are written and tested by one server.

For/l % p in (1,1, 254) do @ ping 192.168.1.% p-n 1 | find "reply from"/I> c: ping.txt

The above command can separately sort out the machines that can be pinged.

The command to modify the gateway is as follows:

Cmd/c netsh interface ip set address name = "Local Connection" source = static addr = 192.168.1.100

Mask = 255.255.255.0 gateway = 192.168.1.1 gwmetric = 1

Modify DNS
Cmd/c netsh interface ip set dns name = "Local Connection" source = static addr = 61.134.1.9

 

 

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.