Matt's Life Bytes
Matthew Sullivan's Thoughts on Security & Tech



Clone ESXi Server Instances Easily

The Problem

Cloning ESXi servers sucks.  Trust me, I do it 4-5 times a year.

You see, multiple times a year I find myself setting up a “master” ESXi server, then needing to clone it over and over to give it out to students for classes, or to teams for our Cyber Defense Competitions.  This process is tedious and ridiculously time consuming.  Here’s why:

  1. ESXi instances don’t follow the hardware MAC addresses by default.  Once installed, the MAC addresses are dictated to the NICs by the ESXi OS settings, meaning that when you clone a box, those MAC addresses are going to collide.  There’s a setting to disable this, but in my experience it often automatically resets after a cloning, meaning I have to re-enter the setting by hand.
  2. ESXi Virtual Machines don’t like moving around.  If you clone an ESXi server you can be guaranteed that everything will explode, because the VMs won’t re-generate new MAC addresses automatically.  Every VM on each cloned box needs to have a new one set manually… EVERY… SINGLE… TIME.  And it sucks.
  3. Each instance has to have its management IP and DNS entries changed by hand after cloning, otherwise conflicts will abound.

Well, I’ve finally had enough.  After wading through pages and pages of busybox/ash shell documentation, I’ve produced two scripts which do all of the above for you.

The Solution

These scripts are only tested on ESXi 5.0; you are using them at your own risk with no warranty!

Also I’m assuming you roughly know what you are doing.  If this is your first spin with ESXi you’ll probably feel overwhelmed by what’s coming.  You’ve been warned.

  • Create your “master” ESXi image. Install everything, get your settings right, and get your VMs all good to go.
  • Set all VMs to use manual MAC addresses and enter something.  It doesn’t matter what you choose, as long as it starts with “00:50:56:”.  This address will auto-regenerate upon cloning anyway.
  • Use wget to grab my scripts.  Alternatively, you can SCP/SFTP them up to your ESXi server, but SSH access will need to be enabled.
    cd /vmfs/volumes/datastore1 (or whatever your datastore path is)
    chmod +x
  • Use vi to modify to your needs.  Some options are located in the top of the file.
  • Shut down your ESXi host and use Clonezilla (or whatever your favorite imaging suite might be) to clone the “master” to new slave hosts
  • This is important: when the clone is done, unplug networking before rebooting.  Why?  Every instance of ESXi will be attempting to use the master’s MAC address, and your network will explode.
  • Unplugged networking yet?  No?  GO DO IT!
  • Now boot the new clones up.   On each, you’ll need to log in via the support console (Alt+F1), then cd /vmfs/volumes/datastore1 (or whatever your datastore path is).
  • Now execute the script with no arguments, and you’ll be presented with a very rudimentary help menu.
  • When you are ready to fly, just execute the script by doing:
    ./ <desired IP suffix> <desired DNS uniqueness>
    (For more understanding about these options, have a look at the help menu and inside the settings area of
  • Once the script is finished your ESXi slave host will reboot.  Once it has reloaded, you can safely plug networking back in.

That’s it!  If you simply grab the scripts and follow this little tutorial you’ll be cloning ESXi servers like a champ in no time at all.  If you find this useful or have questions, feel free to hit me up via e-mail or the comment section (though the comment section is largely ignored by me).

· · · · · ·


  • Larry · October 25, 2011 at 10:27 am

    These scripts will be very useful for CDC teams. Will these be useful for the high school CDCs too?

    Well done!

  • jcran · October 25, 2011 at 9:33 pm

    nice work, this is super handy. :)

  • Rick · June 3, 2012 at 8:00 am

    This just saved me on a project I have been working on. Thanks a lot for sharing this!

  • Brian Hechinger · September 22, 2012 at 11:43 am

    Your downloads are broken, are these scripts still available? This is still an issue, even with 5.1!


  • David · April 19, 2013 at 9:45 pm

    Nice Internal Server Error when you click on the shell scripts links 😉

  • François · April 25, 2013 at 7:48 am

    It’s a very nice script. But the link is broken. Could you please correct it ?

  • Will · August 16, 2014 at 5:18 pm

    .sh links broken.

    Your reverse proxy or whatever is HTTP redirecting to HTTP, hence no one can access the proper location.

    It would be great if you could move the .sh files over to whatever location the reverse proxy is redirecting to when clicking on the links.

  • Hank · November 12, 2014 at 11:52 am

    404 on download – like others posted above – figured it would be fixed since the time of the article :(

  • Bob · December 9, 2014 at 9:34 am

    Connecting to||:80… connected.
    HTTP request sent, awaiting response… 301 Moved Permanently
    Location: [following]
    –2014-12-09 08:32:48–
    Connecting to||:443… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2014-12-09 08:32:48 ERROR 404: Not Found.

  • Oliver · February 22, 2015 at 4:27 pm

    The entire ESXi path has been deleted. although he’s left a few other paths open to public browsing (there is a security hole in there if Matt reads this comment)

  • B · October 21, 2015 at 11:12 am

    Shame the links to the scripts are still broken, would have liked to check these scripts out :(

  • Itpingblugger · November 29, 2015 at 7:54 pm

    I don’t understand what’s the problem here.

    Of course the purpose of cloning is to make a copy or backup and we understand when you deploy them you would have the same copies of IPs, MAC Addresses from the original servers. Unless you are doubling the numbers of ESXI server names, Windows Servers, Domains which is a NO NO in networking! These are basics!

    In Windows world – use sysprep before cloning if you plan to redeploy fresh systems. Cloning means DUPLICATE. Deploying sysprepped cloned system means clearing all the IDs as if you are deploying brand new hardware and fresh copy of software including Operating System.

    You have to be clear what’s your objective here.

Leave a Reply



Theme Design by