DHCP Reservation Entry: Batch file solution


When you get a request to add a printer or any device for DHCP reservation with MAC address, it’s a hassle to find the hosting DHCP servers and have add it on both servers. If you read this you already know how to do it with DHCP MMC console.

To make this process easy, I wrote a batch files for different DHCP server (sets/scopes) and add the reservation in one single step using NETSH command.

I created one batch file for each DHCP servers set which shares the scopes. Without further due, here is my batch file.

REM
REM DHCPReserve.bat
REM Usage: DHCPReserve <Scope> <IP Address> <MAC address> <Description>
REM <Scope> is like 192.168.10.0
REM <IP Address> is assigned IP address for the device, eg., 192.168.10.15
REM <MAC Address> is the device’s MAC address without dash or spaces e.g., 0013FA0191C2
REM <Description> is anything you like about the device
REM
netsh dhcp server <Server1.domain.com> scope %1  add reservedip %2 %3 %4
netsh dhcp server <Server2.domain.com> scope %1  add reservedip %2 %3 %4

Copy and paste the above script in notepad and save it as DHCPReserve.bat. Run it with proper parameters as in remarks section in teh script.

Advertisements

2 thoughts on “DHCP Reservation Entry: Batch file solution

  1. hi,
    How can I run this batch file in code? I want to do reservation for two different machine but I didnt do it.
    thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s