Use PowerShell to Add a Vendor-Specific Class to Windows DHCP
I'm helping a customer migrate from an Infoblox appliance to Windows IPAM.
One of the tasks I've just completed is to take vendor-specific DHCP classes and option definitions from an Infoblox appliance (ISC) dump and convert it to something that Windows Server 2012 DHCP understands. A vendor-specific class ensures that vendor-specific scope options are delivered to just the vendor's devices.
Of course, I used PowerShell to import the settings... here's a sample Infoblox (ISC) setting (exhibit A):
option vendor-class-identifier "Cisco AP c1600";
option vendor-encapsulated-options f1:08:0a:03:0a:f1:0a:07:0a:f1;
And, here's what it looks like in Windows DHCP (exhibit B):
But, I hear you ask, how did we get from A to B?
Well, first up we need to add a vendor-specific class to the Windows DHCP server. I referenced some Cisco documentation and the key bit of information here is contained in the AsciiData property - "Cisco AP c1600" - the vendor class client identifier.
NB - It's worth giving the Cisco documentation a good read, as it details the background information relating to DHCP concepts such as client identifiers, option 60, option 43 and sub-options.
Here's the PowerShell for adding the vendor-specific class:
$VendorClass = @{
Name = "Cisco Aironet 1600 series"
Description = "Vendor Class Indentifier for Cisco AP c1600 Series"
Type = "Vendor"
Data = "Cisco AP c1600"
}
Add-DhcpServerv4Class @VendorClass -ComputerName HALODC01
Here, we're using splatting to supply the parameter values to the Add-DhcpServerv4Class. Notice how the value supplied to the -Data parameter matches that from the Infoblox configuration - option vendor-class-identifier "Cisco AP c1600";
Next, create an option definition for our new class, again, with the aid of splatting:
$OpDef = @{
Name = "Cisco Aironet 1600 IP Provisioning"
Description = "WLAN Controller IP Address Delivery Option (43)"
OptionId = 241
Type = "IPv4Address"
VendorClass = "Cisco Aironet 1600 series"
MultiValued = $true
DefaultValue = "10.3.10.241","10.3.10.241"
}
Add-DhcpServerv4OptionDefinition @OpDef -ComputerName HALODC01
This option definition can be used to deliver the IP addresses of two WLAN controllers to Cisco Aironet 1660 devices from the optionID* 241. On the Infoblox appliance it looked like this - option vendor-encapsulated-options f1:08:0a:03:0a:f1:0a:07:0a:f1;
*actually it's a sub-option of option 43!
Let's pick the HEX apart:
- f1 - this is the optionID 241
- 08 - the number of IP addresses x 4
- 0a:03:0a:f1 - IP address 1... 10.3.10.241
- 0a:07:0a:f1 - IP address 2... 10.7.10.241
We need one last piece of the jigsaw, namely, adding the new option to a scope.
Set-DhcpServerv4OptionValue -OptionId 241 -VendorClass "Cisco Aironet 1600 series" -Value "10.3.10.241","10.7.10.241" -ScopeId "10.241.76.0" -ComputerName HALODC01
And, that's it. Here's the three steps for the conversion:
- Create the Class
- Create the Option Definition
- Assign the scope option
Now to add these steps to a script...