Solved

Change IP address remotely

Posted on 2010-08-18
10
704 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
10 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 68

Accepted Solution

by:
Qlemo earned 500 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
 
LVL 3

Expert Comment

by:VBDotNetCoder
ID: 33470724
That's great info Qlemo, thanks!
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 22

Expert Comment

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

Assisted Solution

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

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 68

Expert Comment

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

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now