Solved

Change IP address remotely

Posted on 2010-08-18
10
703 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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.

Join & Write a Comment

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

22 Experts available now in Live!

Get 1:1 Help Now