Each time I access the Internet from another location, I have to reset the IP address, which is quite time-consuming. So I wrote a batch of requests for automatic setting.
Save the following code as the **. bat file in notepad, and change the IP address, gateway, DNS, and nic name to your own one. Run the command as an administrator.
(1) set the dynamic IP address and obtain it automatically.
@ ECHO OFF
Echo ip address modification Tool
ECHO is setting to automatically obtain the IP address. Please wait ......
Rem NIC is the network name. The system name prevails.
Set NIC = Wireless Network Connection
Rem set NIC = Local Area Connection
Netsh interface ip set address name = "% NIC %" source = dhcp
Netsh interface ip set dns name = "% NIC %" source = dhcp
ECHO ipset successfully BY GAVIN_DING :)
Pause
(2) set static IP addresses
@ ECHO OFF
Echo ip address modification Tool
ECHO is setting static IP. Please wait ......
Set IP = 222.201.189.98
Set MASK = 255.255.255.0
Set GW = 222.201.189.254
Rem NIC is the network name. The system name prevails.
Set NIC = Wireless Network Connection
Rem set NIC = Local Area Connection
Set DNS1 = 222.201.130.30
SET DNS2 = 222.201.130.33
Netsh interface ip set address name = "% NIC %" source = static addr = % IP % mask = % MASK %
Netsh interface ip set address name = "% NIC %" gateway = % GW % gwmetric = 0
Netsh interface ip set dns name = "% NIC %" source = static addr = % DNS1 %
Netsh interface ip add dns name = "% NIC %" addr = % DNS2 %
ECHO ipset successfully BY GAVIN_DING :)
Pause