Change IP address remotely

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.
khfinlayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

khfinlayAuthor Commented:
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
clw3388Commented:
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
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

VBDotNetCoderCommented:
That's great info Qlemo, thanks!
0
senadCommented:
olemo - did you actually try this ?
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Obviously not, since I forgot a ) at the very end (line 10).
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Objection: See my last post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.