Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change IP address remotely

Posted on 2010-08-18
10
708 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 69

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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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 69

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 69

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 69

Expert Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…

829 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