Solved

Change default gateway with a script

Posted on 2008-10-08
6
4,325 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
  • 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now