Set the local connection IP address and DNS in the batch processing script

Source: Internet
Author: User

When using DOS batch processing to set IP addresses, DNS can greatly simplify the network management workload. For example, you need to manually set IP addresses for around 100 computers in the network environment of 192.168.0.1/24, if you set the local connection attribute of each computer in the Internet protocol, this will repeat a lot of work, in fact, each computer sets only the last bit of the IP address, the other is the same, in this way, we can set the IP address by entering only the last digit in batch processing, which greatly reduces our workload ,:

 

Set ip code:

 

1 Set IPL =
2 set/p IPL = enter the value after the last decimal point of the IP address (30-199 ):
3. The IP address is being set for Echo. Please wait...
4 netsh interface IP Set address name = "Local Connection" Source = static ADDR = 192.168.0.% IPL % mask = 255.255.255.0 gateway = 192.168.0.1 1
5 echo.
6. IP address set for Echo!
7 Echo.
8

 

 

Set DNS code:

 

1 Set ISDNs =
2 set/p ISDNs = whether to set DNS (y/N ):
3 if/I "% ISDNs %" = "Y" Goto setdns
4 If/I "% ISDNs %" = "N" Goto showinfo
5
6: setdns
7 Echo is setting DNS. Please wait...
8 netsh interface IP add DNS name = "Local Connection" ADDR = 192.168.0.1
9 netsh interface IP add DNS name = "Local Connection" ADDR = 202.96.209.20.
10: netsh interface IP add DNS "Local Connection" ADDR = 202.96.209.5
11. DNS added by ECHO!
12 goto showinfo
13
14: showinfo
15 echo system time: % DT % TM1 % hour % TM2 % minute % tm3 % second
16 set fn = % computername %
17 echo detection system information ......
18 echo.
19 echo computer name: % FN %
20 echo.
21 echo current user: % username %
22 echo.
23 echo IP, MAC value information:
24 ipconfig/all
25 echo.
26 goto end
27
28: End
29 pause

 

 

Note: Setting IP addresses in XP requires an account with administrator permissions. Setting DNS is not required, but 360 security guard will prompt you to allow it directly.

In win7, you need to "run as administrator". You also need to know whether the network adapter of the current computer is called "Local Connection". Otherwise, name = "Local Connection" needs to be modified.

 

Simple source code:/files/long-gengyun/setip_info.rar

 

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.