Since my first few posts on this got a bit of attention, I thought I’d add some more to this. In today’s post we’ll cover adding or deleting a route, and setting a default route. I’ve got requests for others that will keep the next few weeks worth of VIX posts busy.
We’ll cover this against both a Windows and a Linux guest, because well… VIX is flexible like that. Remember, if you have any trouble, check that your VMware Tools are running, your command syntax is correct, and that you have the right user & password settings.
On Windows:
Traditionally this would be done by logging into the guest OS, and running one of the following commands:
Adding:
Temporary Route: route add 192.168.100.0 mask 255.255.255.0 192.168.15.1 1
Permanent Route: route add -p 192.168.100.0 mask 255.255.255.0 192.168.15.1 1
Deleting:
route delete 192.168.100.0
Doing this in VIX is as simple as:
Adding:
vmrun -T esx -h https://esx/sdk -u cody.bunch -p password -gu guest.user -gp guest.password runProgramInGuest "[datastore] vm/vmx.vmx" c:\windows\system32\route.exe add -p 192.168.100.0 mask 255.255.255.0 192.168.15.1
Deleting:
vmrun -T esx -h https://esx/sdk -u cody.bunch -p password -gu guest.user -gp guest.password runProgramInGuest "[datastore] vm/vmx.vmx" c:\windows\system32\route.exe delete 192.168.100.0
Setting the default was accomplished back in our setting the IP address post.
C:\Program Files\VMware\VMware VIX>vmrun -T esx -h https://esx.example.com/sdk -u nerv\cody.bunch -p apassword -gu Administrator -gp anotherpassword runProgramInGuest “[sanstorage1] test/test.vmx” c:\windows\system32\netsh int ip set address “Local Area Connection” static 192.168.15.25 255.255.255.0 192.1
On Linux
On Linux, where my knowledge is quite limited, I’ve come to understand (thanks Google) that it’s as simple as the “route add –net” commands to add and delete routes. I did find however, that for making this route persistent, can vary across distro of choice, and thus I’ve not included it here.
Adding:
route add –net 192.168.100.0/24 gw 192.168.15.1
Deleting:
route del –net 192.168.100.0/24 gw 192.168.15.1
In VIX:
Before:
Adding:
vmrun -T esx -h http://dc01.nerv.local/sdk -u user -p password -gu root -gp rootpassword runProgramInGuest "[Local
Storage] shell.nerv.local/shell.nerv.local.vmx" /sbin/route add -net 192.168.10
0.0/24 gw 192.168.15.1
Deleting:
vmrun -T esx -h http://dc01.nerv.local/sdk -u user -p password -gu root -gp rootpassword runProgramInGuest "[Local
Storage] shell.nerv.local/shell.nerv.local.vmx" /sbin/route add -net 192.168.10
0.0/24 gw 192.168.15.1
Thank you! If you want to play with Linux but don't have a shell or can't install Linux on your box look at http://on-net.info/shell-accounts/ for a free one.
Interesting. Thanks
With this information that i got in this post I am lucky that i saw this I can finally finish my work.