Thursday, March 8, 2012

Remotely changing the default gateway

Recently I needed to change the default gateway on all the clients residing in a specific subnet. I was able to achieve the  wanted result in two different ways.

For a first bunch of Windows computers I remotely ran the following netsh script:
netsh -r interface ip set address "Local Area Connection" gateway= gw=1
For this to work, you have to manually define the IP address of each computer to update. In the example the IP address of the computer is Please note also that the name of your connection could not be "Local Area Connection" but anything else, so please check.

On a second group of hosts I decided to use Powershell, just for fun.

Here's the Powershell script I used:
$DefGateway = ""
$pc_list = get-content "c:\pclist.txt"
foreach($pc in $pc_list)
    $nics = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $pc -Filter "IPEnabled=TRUE"
    foreach($nic in $nics)
        if($nic.ipaddress -match "192.168.1.") # fetch the right nic based on its IP address
As you can see netsh and powershell are two very powerful tools to administer the IP configuration of your clients. Many more configurations can be done through these tools, so do not hesitate to explore and test to better understand how they work and their extent.

Friday, March 2, 2012


I have just passed the VCP5 certification and I am pretty proud of it. All around it was a tough but fair exam I think. I can at last add the VMWare Certified Professional logo to the MCSE, MCDBA and HP Openview Certified Consultant I already own.

What's next? Becoming a VCAP of course. The VCAP-DCD (for design) is in beta these days and no news about VCAP-DCA (for administration) so I think I'll have to wait a bit.

For more information on becoming a VCAP check out the Saffa Geek blog.

A special thanks goes to Andrea Mauro for his invaluable study notes on VCP5.
Related Posts Plugin for WordPress, Blogger...