Solved

Change default gateway with a script

Posted on 2008-10-08
6
4,457 Views
Last Modified: 2012-08-14
Hi everyone,

I have a Windows 2003 network with 75 XP clients. I want to write a batch file script that I will run as a domain admin remotely against all client PCs to simply change the default gateway address for the "Local Area Connection" only.

I've been trying to write a script using netsh, but the syntax keeps causing me problems.

For example, I would like to change the default gateway from 192.168.1.1 to 192.168.1.5 on the Local Area Connection on all clients. All clients use static addressing.

Thanks for any help you can provide.
 
0
Comment
Question by:travbeav
[X]
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
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:sonickmc
ID: 22675305
What errors are you seeing running netsh?

The correct command should be netsh interface ip set address gateway 192.168.1.5
0
 
LVL 14

Expert Comment

by:igor-1965
ID: 22676559
Try this one first:

netsh interface ip set address name="Local Area Connection" gateway=192.168.1.5 gwmetric=0

If not working then try this:

netsh interface ip delete address "local area connection" gateway=all
netsh interface ip add address "local area connection" gateway=192.168.1.5 gwmetric=0
0
 

Author Comment

by:travbeav
ID: 22677613
In the above commands, where is the remote system name/IP specified?
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 14

Expert Comment

by:igor-1965
ID: 22678106
The commands should be run on the systems, not remotely. To launch it on the remote systems you have to use a workaround. For example, you could download and use PsExec utility: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

Read carefully the usage / parameters. You might enter the computer name directly (like below) or use a file containing the list of the comouters.

psexec \\<computer> cmd /C "netsh interface ip set address name="Local Area Connection" gateway=192.168.1.5 gwmetric=0"
0
 
LVL 14

Accepted Solution

by:
igor-1965 earned 250 total points
ID: 22678131
Correction: psexec \\<computer> cmd /C netsh interface ip set address name="Local Area Connection" gateway=192.168.1.5 gwmetric=0
0
 

Author Closing Comment

by:travbeav
ID: 31504522
Thanks...works great.  Exactly what I was looking for.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

An article on effective troubleshooting
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

622 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