travbeav
asked on
Change default gateway with a script
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.
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.
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
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
ASKER
In the above commands, where is the remote system name/IP specified?
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"
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"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks...works great. Exactly what I was looking for.
The correct command should be netsh interface ip set address gateway 192.168.1.5