Easily convert IP addresses and DNS settings
Problem description:
For people who use laptops, they may often need to use them in different networks, such as the company network, customer network, or home broadband network. For this reason, you often need to set IP addresses and DNS servers based on the no-need network. For example, if you use a general broadband network at home, the IP address is automatically obtained, in the company office or customer office, a fixed IP address and DNS server are usually specified. It is very troublesome to set the location of each change. Therefore, this article describes the use of netsh commands and bat batch files for quick setting.
Code Description:
1. Set the fixed IP address and DNS server of the office or customer office
In notepad, save the following content as office. BAT:
@ Echo start to set the IP address used by the office...
@ Netsh interface IP Set address "Local Connection" static 172.20.128.145 255.255.255.0 172.20.128.1 1
@ Netsh interface IP Set DNS "Local Connection" static 172.16.80.1 primary
@ Netsh interface IP add DNS "Local Connection" 202.96.209.20.
@ ECHO: The current IP address is:
@ Ipconfig/all
@ Echo note: the IP address has been set as the IP address used by the Office. Please press any key to start using it ......
@ Pause
2. Set the method for Automatically Obtaining IP addresses and DNS servers
In notepad, save the following content as autoip. BAT:
@ Echo start to set automatic acquisition of Dynamic IP addresses...
@ Netsh interface IP Set address "Local Connection" DHCP
@ Netsh interface IP Set DNS name = "Local Connection" Source = DHCP
@ ECHO: The current IP address is:
@ Ipconfig/all
@ Echo note: the IP address has been set to automatically obtain the dynamic IP address. This applies to networks with dynamically assigned IP addresses such as home broadband. Please press any key to start using it ......
@ Pause
Usage:
Double-click the preceding file to complete the settings.