RSS

Tag Archives: msdhcp

Changing a msdhcp scope’s IP range using netsh in batch file

This batch file will:

  • dump the current scope’s definition
  • Extract the line to “add iprange”
  • remove existing iprange
  • add the new iprange

You need 4 parameters: dhcp server ip, scope, new start range, new end range

netsh dhcp server %1 scope %2 dump > temp_%2.txt

find temp_%2.txt /i “add iprange” | find /i “dhcp server” > temp_%2_1.txt

for /f “tokens=1,2,3,4,5,6,7,8,9 delims= ” %%a in (temp_%2_1.txt) do _
netsh dhcp server %1 scope %2 delete iprange %%h %%i

netsh dhcp server %1 scope %2 add iprange %3 %4

Advertisements
 
Leave a comment

Posted by on June 10, 2011 in Scripts, Windows, Windows CMD

 

Tags: ,

Script to get all active msdhcp client leases using netsh

Here is a quick batch file you can use to get active leases of all scopes for a list of ms dhcp servers. Assuming that you already done a dump using “netsh dhcp server \\host dump” to a file called dhcp_dumps.txt:

find .\dhcp_dumps.txt /i "add scope" | _
find /i "dhcp server" > .\ts.txt
del /q .\getac.txt

for /f "tokens=1,2,3,4,5,6,7 delims= " %%a in (.\ts.txt) do _
@echo dhcp server %%c scope %%f show clients 1 >> getac.txt

netsh -f .\getac.txt > .\ac_list.txt

Note: Updated with a better script

Also note: _ is used as a wrapper for the blog, its not used in the actual script

 
Leave a comment

Posted by on June 1, 2011 in Scripts, Windows, Windows CMD

 

Tags: ,

Long DHCP lease causes client’s DNS name to disappear

Recently, we found that some servers’ and workstations’ host record (A RR) has been dropped off our DNS servers. All the machines were running a DHCP clients and we are using MS product for both DHCP and DNS.

The DHCP servers are configured to update the host record on behalf of the client. When we checked the scopes, we found that they have a 30 days lease duration. Very quickly it was established that its possible that the host records could have gone stale in the DNS due to the lease duration and got scavenged.

A quick chat with our DNS team and we found our that the DNS servers have a setting of about 14 days before a record is scavenged in a daily routine. Namingly the values are 7 days for non-refresh interval and 7 days for refresh interval.  (see DNS Aging/Scavenging Simplied) Read the rest of this entry »

 
Leave a comment

Posted by on May 29, 2009 in Windows

 

Tags: ,

DHCP: Adding a new vendor class for Sun Ray servers

I was asking to add a new vendor class for a set of subnets hosted by Sun Ray servers from the networking team into our MSDHCP servers. It took me a while to figure out as this was the first time I had done this, but I managed to get it up.

If you have a subnet that require setup of vendor specific dhcp options for sun ray server, you can use the following text file and run netsh on your dhcp server. I did not add all the available options for sun ray servers, but only those required by my network team, but I am sure that you are smart enough to figure that out!

Replace with and actual IP address

—- start of text file —–
# =====================================
# Add Classes
# =====================================

Dhcp Server Add Class “Sun Ray DHCP Option” “” 53554e572e4e6577542e53554e57 1 b

# =====================================
# Add Optiondef
# =====================================

Dhcp Server Add Optiondef 23 “NewTVer” STRING 0 vendor=”Sun Ray DHCP Option” comment=”Specifies which firmware version to upgrade to” “”
Dhcp Server Add Optiondef 24 “LogHost” IPADDRESS 0 vendor=”Sun Ray DHCP Option” comment=”Log level for host” 0.0.0.0
Dhcp Server Add Optiondef 25 “LogKern” BYTE 0 vendor=”Sun Ray DHCP Option” comment=”Log level for kernel” 0
Dhcp Server Add Optiondef 26 “LogNet” BYTE 0 vendor=”Sun Ray DHCP Option” comment=”Log level for network” 0
Dhcp Server Add Optiondef 27 “LogUSB” BYTE 0 vendor=”Sun Ray DHCP Option” comment=”Log level for USB” 0
Dhcp Server Add Optiondef 28 “Log Vid” BYTE 0 vendor=”Sun Ray DHCP Option” comment=”Log level for video” 0
Dhcp Server Add Optiondef 29 “LogAppl” BYTE 0 vendor=”Sun Ray DHCP Option” comment=”Log level for application” 0
Dhcp Server Add Optiondef 31 “FWSrvr” IPADDRESS 0 vendor=”Sun Ray DHCP Option” comment=”Firmware server IP address (needed for firmware upgrade)” 0.0.0.0
Dhcp Server Add Optiondef 35 “AltAuth” IPADDRESS 1 vendor=”Sun Ray DHCP Option” comment=”Alternate set of Sun Ray server IP addresses” 0.0.0.0

—- end of text file —–

 
Leave a comment

Posted by on January 8, 2008 in Windows

 

Tags: