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:
dim vs, vn1
‘Connect to Virtual Server
Set vs = CreateObject(“VirtualServer.Application”)
set vn1 = vs.VirtualNetworks.item(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.