Modify the IP address with a script

Source: Internet
Author: User
Tags exit goto

In Windows you want to quickly modify the IP address through the script, it is very simple, then the specific content and how to do it! Now let's take a look!

[Plain]

@echo off

: Main

Cls

Color 02

Echo.---------------------------------------------

Echo. Welcome to the IP address switch script made with Prudentwoo

Echo. Scripted script switching for Windows platforms

Echo. Http://www.prudentwoo.com Prudentwoo?

Echo.--------------------------------------

Echo. 1. WLAN (Wireless card preset IP address setting)

Echo. 2. Ethernet (Ethernet network adapter preset IP address setting)

Echo. 3. IP Address Customization

Echo. 4. Clean up the DNS cache

Echo. 5. Turn WiFi hotspot on or off

Echo. 6. IP address Information

Echo. 7. Exit

Echo.--------------------------------------

set/p choice= Please enter the execution item number:

Echo.

If%choice%==1 goto Wlan

If%choice%==2 goto Ethernet

If%choice%==3 goto Ip-selfset

If%choice%==4 goto Clear DNS

If%choice%==5 goto WIFI

If%choice%==6 goto Ip_info

If%choice%==7

Cls

Goto END

@rem The following is the wireless network card preset IP address setting batch processing

: Wlan

Cls

Color 03

echo. You are performing a Wi-Fi IP address setting operation!

Echo.------------------------------

Echo 1. Set to Wi-Fi DHCP

Echo 2. Set Wi-Fi static public IP

Echo 3. Return

Echo.-----------------------------

set/p choice= Please select the execution item number:

If%choice%==1 Goto 1

If%choice%==2 Goto 2

If%choice%==3 Goto 3

: 1

echo. DHCP settings in progress, please wait a moment ... echo. IP address is getting automatically from DHCP ...

netsh interface ip set address "Wi-Fi" DHCP

Echo. DNS address is being automatically obtained from DHCP ...

netsh interface ip set DNS "Ethernet" DHCP

echo. All settings Complete!---

@Pause

Goto END

: 2

Echo. The Wi-Fi public IP setting is in progress, please wait ...

Echo.ip Address =192.168.1.123

echo. Subnet Mask =255.255.255.0

echo. Default Gateway =192.168.1.1

echo. Preferred dns=10.252.8.5

echo. Alternative dns=10.252.8.4

NET interface IP set address name= "Wi-Fi" source=static

addr=192.168.1.123 mask=255.255.255.0 >null

NET interface IP set address name= "Wi-Fi" gateway=192.168.1.1

Gwmetric=1 >null

NET interface IP set DNS name= "Wi-Fi" source=static addr=10.252.8.5

NET interface IP Add DNS name= "Wi-Fi" 10.252.8.4 index=2

echo All settings complete!

echo Please press any key to exit ...

@Pause

Goto END

: 3

Goto Main

@rem The following is the Ethernet network card preset IP address setting batch processing

: Ethernet

Cls

Color 2f

echo. You are performing the Ethernet IP address setting operation!

Echo.-----------------------------------

Echo 1. Set Ethernet to DHCP mode

Echo 2. Set Ethernet static public network IP1 (office network)

Echo 3. Set Ethernet static public network IP2 (dorm network)

Echo 4. Return

Echo.-----------------------------------

set/p choice= Please select the execution item number:

If%choice%==1 Goto 1

If%choice%==2 Goto 2

If%choice%==3 goto 3 if%choice%==4 goto 4

: 1

Cls

Color 26

echo. DHCP settings in progress, please wait a moment ...

Echo. IP address is getting automatically from DHCP ...

netsh interface ip set address name = "Ethernet" Source=dhcp

Echo. DNS address is being automatically obtained from DHCP ...

netsh interface ip set DNS "Ethernet" Source=dhcp

echo. All settings are complete!

@Pause

Goto Enthernet

: 2

Cls

Color 35

ECHO is in the Ethernet public network static IP1 (office network) settings, please wait ...

Echo.

echo. Set the parameters to:

Echo.---------------------------

Echo.ip Address =198.9.2.123

echo. Subnet Mask =255.255.255.0

echo. Default Gateway =198.9.2.1

echo. Preferred dns=202.112.20.131

Echo.---------------------------

echo. Setting the IP parameters above ...

Ipconfig/release

netsh interface ip add address name= "Ethernet" addr=198.9.2.123 mask=255.255.255.0 gateway=198.9.2.1

netsh interface ip add address name= "Ethernet" addr=10.2.2.234 mask=255.255.255.0 gateway=10.2.2.254

netsh interface ip add address name= "Ethernet" addr=10.0.0.10 mask=255.0.0.0

netsh interface ip add address name= "Ethernet" addr=192.168.133.20 mask=255.255.255.0

netsh interface ip add address name= "Ethernet" addr=192.168.54.345 mask=255.255.255.0

netsh interface ip add address name= "Ethernet" addr=192.168.7.1 mask=255.255.255.0

netsh interface ip add dns name = "Ethernet" addr = 202.106.0.20

netsh interface ip add dns name = "Ethernet" addr = 211.147.6.3

netsh interface ip add dns name = "Ethernet" addr = 202.106.0.21

netsh interface ip add dns name = "Ethernet" addr = 202.105.12.226

netsh interface ip add dns name = "Ethernet" addr = 61.144.56.100

netsh interface ip add dns name = "Ethernet" addr = 202.96.128.68

netsh interface ip add dns name = "Ethernet" addr = 202.96.128.86

echo. All settings are complete!

@Pause

Goto Ethernet

: 3

ECHO is in the Ethernet public network static IP2 settings (Dorm network), please wait ...

Echo.

echo. Set the parameters to:

Echo.---------------------------

Echo.ip address = 192.168.1.33

echo. Subnet Mask =255.255.255.0

echo. Default Gateway =192.168.1.33

echo. Preferred dns=61.144.56.100

Echo.---------------------------

Ipconfig/release

netsh interface ip add address name= "Ethernet" addr=192.168.1.33 mask=255.255.255.0 gateway=192.168.1.1

netsh interface ip add dns name = "Ethernet" addr = 202.106.0.20

netsh interface ip add dns name = "Ethernet" addr = 211.147.6.3

netsh interface ip add dns name = "Ethernet" addr = 202.106.0.21

netsh interface ip add dns name = "Ethernet" addr = 202.105.12.226

netsh interface ip add dns name = "Ethernet" addr = 61.144.56.100

netsh interface ip add dns name = "Ethernet" addr = 202.96.128.68

netsh interface ip add dns name = "Ethernet" addr = 202.96.128.86

echo. All settings are complete!

@Pause

Goto Enthernet

: 4

Goto Main

@rem The following is a custom batch with IP address

: Ip-selfset

Cls

echo. You are performing the Ethernet IP address custom setting operation!

: ip1

Cls

Color 13

Echo. IP custom settings start ....

Echo.

echo starts setting IP and subnet masks

set/p saddr= Please enter a static address:

if/i "%saddr%" = = "goto ip1

set/p mask= Please enter the subnet mask:

if/i "%mask%" = = "goto ip1

set/p gateway= Please enter the default gateway:

if/i "%gateway%" = = "goto ip1

Goto Ip_judge

: Ip_judge

Cls

echo. The IP address parameters you entered are as follows:

Echo. ————————————————————

Echo. IP Address:%saddr%

Echo. Subnet Mask:%mask%

Echo. Default gateway:%gateway%

Echo. ————————————————————

Echo.

echo. If the above parameters are correct, press Y to continue, error please press N to return to reset!

Echo.

set/p choice= Your choice:

If "%choice%" = = "N" goto IP1

If "%choice%" = = "n" Goto ip1

If "%choice%" = = "Y" goto ipaddr

If "%choice%" = = "y" goto ipaddr goto Ip_judge

Echo.

: ipaddr

cmd/c netsh interface ip set address name= "Local Area Connection" Source=static addr=%saddr%

mask=%mask% gateway=%gateway% gwmetric=1 >nul

Goto Ipdns

: Ipdns

Cls

Echo starts setting up a DNS server

set/p dnsaddr= Please enter the DNS server:

if/i "%dnsaddr%" = "Goto:ipdns"

@rem The following statement to set the DNS

cmd/c netsh interface ip set DNS name= "Local Area Connection" Source=static addr=%dnsaddr%

Register=primary >nul

echo. Start setting up a DNS standby server

set/p dnsaddr2= Please enter an alternate DNS server:

if/i "%dnsaddr2%" = "Goto:ipdns"

Goto Dns_judge

:D Ns_judge

Cls

Echo.

Echo. ——————————————————————————

Echo.

Echo. DNS Preferred server:%dnsaddr%

Echo.

Echo. DNS standby server:%dnsaddr2%

Echo.

Echo. ——————————————————————————

echo. If the above DNS parameters are correct, press Y to continue, otherwise press N to return to reset!

Echo.

set/p choice= Your choice:

If "%choice%" = = "N" goto Ipdns

If "%choice%" = = "n" Goto Ipdns

If "%choice%" = = "Y" goto IPDNS2

If "%choice%" = = "Y" goto ipdns2

Goto Dns_judge

: Ipdns2

cmd/c netsh interface ip add DNS name= "Local area Connection" addr=%dnsaddr2%

index=2 >nul

echo. Setup Complete @pause

Goto Main

if errorlevel 2 goto main

if errorlevel 1 goto end

: Clear DNS

Cls

CMD/C Ipconfig/flushdns

Echo. DNS cache cleanup is complete!

@pause

Goto Main

: WIFI

Cls

echo. You are performing a WiFi hotspot setup operation!

Echo.-----------------------------------

Echo 1. Turn on WiFi Hoc

Echo 2. Turn off WiFi Hoc

Echo.-----------------------------------

set/p Choice= Enter your selection number:

If "%choice%" = = "1" goto start

If "%choice%" = = "2" goto stop

: Start

Cmd/c Netsh wlan start hostednetwork

@Pause

Goto Main

: Stop

@Pause

Goto Main

cmd/c Netsh wlan stop hostednetwork

: Ip_info

Cls

Color 5f

Echo. The following is your IP address information:

CMD/C Ipconfig/all

@pause

Goto Main

Summary: Netizens through the above content to understand the rapid modification of IP content and methods, is not the problem of this area know more Ah! Now don't hesitate to learn!

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.