Adding bulk DHCP reservations

As a System Admin you deploy DHCP server to give out IP addresses to client computers dynamically. While this eliminate boring routine work and overheads, you still need to control the IP assignment process to manage who get access to the network. This can be easily achieved by reserving an IP address for each client as opposed to letting them acquire a lease dynamically. In a large organization, it’s not easy task to assign a long list of IP address manually.

To accomplish above requirement, we can use DHCP PowerShell (introduced after Windows Server 2012) to manage DHCP reservations. Below are few of the cmdlets that can be used in DHCP Powershell.

Adds a DHCPv4 or DHCPv6 reservation to a DHCP server

Add-DhcpServerv4Reservation
Add-DhcpServerv6Reservation

Deletes DHCPv4 or DHCPv6 reservation(s) from a DHCP server

Remove-DhcpServerv4Reservation
Remove-DhcpServerv6Reservation

Gets DHCPv4 or DHCPv6 reservations from a DHCP server

Get-DhcpServerv4Reservation
Get-DhcpServerv6Reservation

Modifies the properties of a DHCPv4 or DHCPv6 reservation

Set-DhcpServerv4Reservation
Set-DhcpServerv6Reservation

Lets consider an example where we have below reservations.csv file which contains a list of client computers with IP address reservations.

ScopeId,IPAddress,Name,ClientId,Description
10.10.10.0,10.10.10.10,Peter-Laptop,1a-1b-1c-1d-1e-1f,Reserved for Peter
20.20.20.0,20.20.20.11,Sam-Laptop,2a-2b-2c-2d-2e-2f,Reserved for Sam
30.30.30.0,30.30.30.12,Lucy-Laptop,3a-3b-3c-3d-3e-3f,Reserved for Lucy

ScopeId specifies the identifier (ID) of the scope in which the reservation is being created. ClientId specifies the unique identifier (ID) for the client. For Windows clients, the MAC address is used as the client ID.

Above CSV file can be run on DHCP Powershell with below command and should be run with Administrator privilege.

Import-Csv –Path C:\ADSetup\reservations.csv | Add-DhcpServerv4Reservation -ComputerName example.domain.com

One thought on “Adding bulk DHCP reservations

Leave a Reply

Your email address will not be published. Required fields are marked *