Configuring and enabling the Virtual DHCP Server with VBScript

Configuring and enabling the Virtual DHCP Server with VBScript

  • Comments 2

Under Virtual Server it is possible to configure a virtual DHCP server on any virtual network.  This is handy if you are running virtual machines in a private environment and do not want to have a dedicated DHCP server.  As with everything else under Virtual Server - this can be configured with VBScript:

Option Explicit
 
dim vs, vn1
 
'Connect to Virtual Server
 
Set vs = CreateObject("VirtualServer.Application")
 
set vn1 = vs.VirtualNetworks.item(1)
 
vn1.DHCPVirtualNetworkServer.ConfigureDHCPServer _
         "10.10.0.0", _
         "255.255.0.0", _
         "10.10.0.16", _
         "10.10.255.254", _
         "10.10.0.1"
 
vn1.DHCPVirtualNetworkServer.ConfigureDHCPLeaseTimes 129600, 64800, 97200
 
vn1.DHCPVirtualNetworkServer.DefaultGatewayAddress = "10.10.0.2"
vn1.DHCPVirtualNetworkServer.DNSServers = "10.10.0.2"
vn1.DHCPVirtualNetworkServer.WINSServers = "10.10.0.2"
vn1.DHCPVirtualNetworkServer.IsEnabled = true

This script configures and enables the DHCP server on the first virtual network on a server.  Some of the calls here are fairly obvious (DefaultGatewayAddress, DNSServers, WINSServers, etc...) but some are a bit more cryptic.  The three parameters for ConfigureDHCPLeaseTimes are the lease time, lease renewal time and lease rebinding time (all specified in seconds).  The ConfigureDHCPServer call takes parameters of the network address to be used, the subnet mask, the starting IP address for the DHCP server to offer, the ending IP address for the DHCP server to offer and the IP address to be used by the DHCP server.

A couple of key 'gotchas' to be aware of here are that the DHCP server IP address must be below the DHCP range specified.  Also the starting address for the DHCP IP range must be above the first 16 addresses of the network.

Cheers,
Ben

Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
  • Pardon me if this has already been covered. Is it possible to create a "Test domain" (test.corporate.com) inside an enterprise where in the test domain is completely invisible from outside but the machines in the test domain can see the external network.

    I want to deploy a test domain for BTS 2006 R2 Beta using Virtual Server with four machines (1 - AD, 2-SQL Server, 3 - BTS, 4 - XP Client) and still see the external corporate network. Can you provide me some pointers to this.

    Thanks.

  • A partial answer to Kris is that I would do it the same way I did on a real network, with one of the servers (in this case a guest) doing NATing and proxying.  But I've forgotten most details of how I did it nearly 5 years ago.

Page 1 of 1 (2 items)