Solved

Change default gateway with a script

Posted on 2008-10-08
6
4,353 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
An article on effective troubleshooting
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

825 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