See how the master teaches you how to change the IP address using the command line.

  

In Windows, if you want to set the IP address, you usually go to “local connection"->" attribute”, manually set the IP to be changed. address. In fact, you can also set the IP address on the command line. If your IP needs to switch back and forth between several IPs, you can use the netsh command to change it:

1. Enter the CMD command line;

Click “Start”->“Run ”, enter “cmd”, enter,

2. Set IP:

Set Dynamically Obtain IP Address (DHCP)


Settings Fixed IP


Parameter Description:

1.name: The name of the network connection, generally "local connection". You can see it in “Control Panel”->“Network Connections”.

2.source: The way to get IP. Dynamically, it is dhcp. If it is set manually, it is static.

3.addr: The IP address to be set.

4.mask: Subnet mask.

5.gateway: Gateway address.

6.gwmetric: The number of gateway hops, which can be set to an integer value or set to “automatic":auto.

3.Setting DNS:

Obtaining DNS automatically


Setting up a single DNS manually


Manual setting Multiple DNS


Parameter Description:

1.name: The name of the network connection, generally "local connection". You can see it in “Control Panel”->“Network Connections”.

2.source: The way to get IP. Dynamically, it is dhcp. If it is set manually, it is static.

3.addr: The IP address to be set.

4.register:

5.none: Disable dynamic DNS registration.

6.primary: Register only under the primary DNS suffix.

7.both: Register under the primary DNS suffix and also under a specific connection suffix.

8.index: Set the serial number of the DNS.

4. Write a batch file for setting IP/DNS:

After knowing how to set up IP and DNS, you can write a BAT file yourself:

Create a new text For the documentation, change the suffix to “.bat”;

Edit “.bat” The contents of the file are the above setting commands. For example:


When running, double-click the bat file and wait for the settings to complete.

For detailed instructions on using the netsh command, you can view it by typing the netsh /? command on the command line. I will not explain it here. I hope it will be useful to you.

Copyright © Windows knowledge All Rights Reserved