First, add IP address and default gateway (is added, to reset or update the original IP, please see the 3rd):
netsh interface ip add address
Usage: Add address [name=]<string> [[ADDR=]IP address [mask=]ip Subnet mask]
[[Gateway=]ip address [Gwmetric=]integer]
Parameters:
Name-ip interface name.
Addr-The IP address to add to this interface.
Mask-Specifies the IP subnet mask for the IP address.
Gateway-Specifies the default gateway for the IP address.
Gwmetric-Metric for the default gateway.
Remarks: Adds an IP address to an interface configured with a static IP address and
The default gateway.
Example:
Add address "Local area Connection" 10.0.0.2 255.0.0.0
Add address "Local area Connection" gateway=10.0.0.3 gwmetric=2
The first command adds a static IP address 10.0.0.2 to the local connection interface, and the subnet mask
Is 255.0.0.0. The second command adds an IP address to the interface with a gateway metric of 2
10.0.0.3 as the second default gateway.
My example:
(1) netsh interface ip add address "localconnection" 172.20.0.49 255.255.252.0
This command sets LocalConnection IP to 172.20.0.49, and the subnet mask is 255.255.252.0
(2)
C:/>netsh Interface IP Add address "localconnection" gateway=172.20.0.254 gwmetric=1
This command sets the default gateway for LocalConnection to 172.20.0.254, and the default gateway has a metric of 1
Second, add DNS:
netsh interface ip add dns?
Usage: Add DNS [name=]<string> [Addr=]<ip address> [[Index=]integer]
Parameters:
Mark values
Name-names of the interfaces that add DNS servers.
Addr-The IP address of the DNS server that was added.
Index-for the specified DNS server address
Specifies the index (preference).
Description: Statically add a new DNS server IP address or re-index the list of existing DNS server addresses to modify DNS server preferences.
For example:
Add DNS "Local area Connection" 10.0.0.1
Add DNS "Local area Connection" 10.0.0.3 index=2
My example:
netsh interface ip add dns "LocalConnection" 172.20.0.1
netsh interface ip add dns "LocalConnection" 202.96.128.68 index=2
Third, set IP address, default gateway and DNS:
netsh interface ip set address local static 172.20.0.49 255.255.252.0 set IP and subnet masks
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
(Set address Name= "LocalConnection" Source=dhcp this bar indicates IP from the DHCP server)
netsh interface IP set DNS "LocalConnection" static 172.20.0.1
(Set DNS Name= "LocalConnection" source=dhcp)
Iv. Comprehensive Example
netsh interface IP set address local static 172.20.0.49 255.255.252.0
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
netsh interface IP set DNS "LocalConnection" static 172.20.0.1
netsh interface ip add dns "LocalConnection" 202.96.128.68 index=2
The above commands are batch processed:
Edit Setip.bat
netsh interface IP set address local static%2 255.255.252.0
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
netsh interface IP set dns '%1 ' static 172.20.0.1
netsh interface ip add dns "%1" 202.96.128.68 index=2
The Setip.bat command usage is:
SetIP network Interface name IP address
For example:
SetIP LocalConnection 172.20.0.49
Netsh Set DNS
Start > Run input cmd into doc operating system
1, input command netsh return
2, Input command interface carriage return
3, Input command IP carriage return
4, set DNS set DNS "local connection" static 202.96.209.5
5. Set up alternate DNS set add DNS "Local Area Connection" 202.96.209.133
Note: "Local Area Connection" varies depending on the machine. (Native Control Panel Network connection name) 202.96.209.5 is a DNS server for Shanghai Telecom, where DNS servers can be searched online.