Solved

Change default gateway with a script

Posted on 2008-10-08
6
4,286 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
Comment Utility
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
Comment Utility
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
Comment Utility
In the above commands, where is the remote system name/IP specified?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 14

Expert Comment

by:igor-1965
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks...works great.  Exactly what I was looking for.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

5 Experts available now in Live!

Get 1:1 Help Now