5

We need to be able to create a way to reboot virtual machines in the lab every 20 minutes automatically.

Is there any way this can be done in vSphere 5?

5
  • 4
    Can't you do that from system itself ? Like creating scheduled restart in windows/ cronjob in linux? Or it must be in lower lvl ?
    – Alan
    Apr 3, 2012 at 5:23
  • 2
    No My Friend, Im Running vulnerable machine for metasploit practice. now ones that system exploit so it has to restart. i'm not available online all the time, so i want to manage something like automatically reboot my virtual machines in every 20 mints.
    – Ashish
    Apr 3, 2012 at 5:38
  • 2
    Just a thought... have you considered the possibility that someone might escape the VM and take over the hypervisor?
    – Ladadadada
    Apr 3, 2012 at 10:23
  • What is the reason for you to reboot an exploited machine? Do you mean rebuild a machine every 20 minutes?
    – Rilindo
    Apr 3, 2012 at 13:05
  • @Rilindo If the exploit only resides in memory, than a reboot would fix. Apr 3, 2012 at 19:46

3 Answers 3

8

I don't have access to vSphere now but it should be like this:

  1. Go to scheduled task (Home->...)
  2. Create new task changing VM power state
  3. Select virtual machine
  4. Select power operation option "Reset"
  5. Select Frequently
  6. Finish

Alternatively You can use vSphere CLI :

http://pubs.vmware.com/vsphere-50/topic/com.vmware.vcli.examples.doc_50/cli_manage_vms.10.6.html

3
  • I'm Running vulnerable machine for metasploit practice. And I Created a online lab so any one can join and play with that machines. now ones that system exploited, So i have to restart the system. i'm not available online all the time, so i want to manage something like automatically reboot my virtual machines in every 20 mints
    – Ashish
    Apr 3, 2012 at 9:24
  • is that the same effect as hitting the reset button or issuing a reset command through the OS?
    – Mauro
    Apr 3, 2012 at 9:25
  • 1
    ...I'm missing why the solution of resetting the machine isn't the same as resetting it periodically. Alternatively you should script a way to roll back the machine from snapshot every X minutes. Better than rebooting. Apr 3, 2012 at 12:59
1

I would use a vSphere scheduled task for this, like Alan said.

  • "Power on": turns on the power
  • "Power off": turn off the power
  • "Shut down": tidy shutdown of the guest OS
  • "Suspend": tidy suspend of the guest OS
  • "Reset": power-cycle the guest (basically power-off then power-on)

In addition, I don't see any point in rebooting a broken machine, so you could also use non-persistent disks on it, so that when the VM reboots, it reverts back to a known good state. Otherwise rebooting a hacked machine just results in a hacked machine...

There is an obvious problem with a scheduled restart though: what happens if I connect to start testing my exploit at 13:59, and the restart is scheduled for 14:00?

0

Why don't you simply create a bat file

having code

shutdown -r -f -t 1200000 ;

and create a schedule to execute it

1
  • This relies on the machine being up and running, though. Much better to get VMWare to do it.
    – Dan
    Apr 3, 2012 at 9:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .