Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change default gateway with a script

Posted on 2008-10-08
6
Medium Priority
?
4,497 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
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…

704 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