[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Change IP address remotely

Posted on 2010-08-18
10
Medium Priority
?
723 Views
Last Modified: 2012-05-10
Hello,
I need a script to change the IP addresses of approximately 50 computers from 192.168.217.... to 192.168.221..... I nother words I need to change just the third octet. How would I be able to force all the computers to change their IP and reboot. I still have DHCP server enabled but all computers have been set to static addresses. I will also be turning off DHCP.

So I need a script to change the IP addresses of all the windows XP Pro PCs and reboot if necessary. PCs already are set to static addresses and need to reboot if necessary.
0
Comment
Question by:khfinlay
8 Comments
 

Author Comment

by:khfinlay
ID: 33470132
Forgot. I will also need to change the Gateway, DNS (x2) and WINS. Those will bethe same for all machines ie same DNS,Gateway and WINS for all the XP machines just the servers will also have new IP addresses.
0
 
LVL 3

Expert Comment

by:clw3388
ID: 33470349
I know you can use netsh to reset the ip address, gateway and dns on a local box you would simply run "netsh int ip reset" so I don't see any reason why we couldn't do this from a batch file that would look something like this

@ECHO OFF  
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = "Local Area Connection" source = dhcp
ECHO Resetting DNS For DHCP
netsh int ip set dns name = "Local Area Connection" source = dhcp
ECHO Resetting Windows Internet Name Service (WINS) For DHCP
netsh int ip set wins name = "Local Area Connection" source = dhcp


Creating the batch file and using group policy to push it should do the trick, of course all systems will be running dhcp now.
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 33470364
An IP address change does not require reboot, so we do not need to care about that.
If we are talking about XP, I would use the following .cmd script, running from a central location. It loops thru all (reachable) PCs and changes the IP data "locally". You need psexec from www.sysinternals.com in the same location as the .cmd script. Gateway, DNS and WINS are example addresses, change to your needs. You might have to change "LAN" to the real NIC name as shown in Network Neighbourhood properties, that differs sometimes.

We could put in some more intelligence, like remembering the IPs we already have changed, but because of the PING that should not matter much.
@echo off
for /L %%C in (1 1 254) do (
  ping 192.168.217.%%C -n 1 -w 50 >nul && ((
    echo set address "LAN" source=static addr=192.168.221.%%C
    echo set address "LAN" gateway=192.168.221.1 gwmetric=0
    echo set dns "LAN" source=static addr=192.168.221.2 register=BOTH
    echo add dns name="LAN" addr=192.168.221.3 index=2
    echo set wins name="LAN" source=static addr=192.168.221.4
  ) | psexec \\192.168.217.%%C -u Domain\User -p Password netsh interface IP
)

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:VBDotNetCoder
ID: 33470724
That's great info Qlemo, thanks!
0
 
LVL 22

Expert Comment

by:senad
ID: 33471737
olemo - did you actually try this ?
0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 2000 total points
ID: 33472726
Obviously not, since I forgot a ) at the very end (line 10).
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 33936478
The code shown in http:#a33470364 (with the small correction of http:#a33472726) would work for sure in the described scenario. If not granting an Accept, it is at least a PAQ.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 33936481
Objection: See my last post.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question