How to find out how many more addresses are available in the DHCP server?


I got a couple of questions from a
collegue regarding configuring DHCP server from a client machine. Before you
can configure the DHCP server from a client machine like XP through netsh or
MMC, you need to install something. Please refer: http://blogs.msdn.com/anto_rocks/archive/2005/04/05/405511.aspx


Now coming to the questions:

1)    
from a client side, I would like to check if the server has additional
leases.

a.    
assume that the client doesn’t have admin privilege to the DHCP server

[AntoAMJ]:
If the client does not have the admin/user priveledge to configure the DHCP
server, then the only way to determine whether the server has additional leases
is to send a DHCP DISCOVER packet and waiting for a DHCP OFFER to come. If the
DHCP OFFER has a valid address, then the server has additional leases. To make
sure that the DHCP server does not commit the lease to this client, abstain
from sending the DHCP REQUEST in response to the OFFER. This way the address
which is given to the client will be reclaimed automatically. Care must be
taken so that an artificial MAC address is put into the DISCOVER so that the
DHCP server does not identify this request to the actual client but treats it
as a new client. This is needed if the client has already an valid lease from
the same DHCP server. This is a proper hack. Don’t do this unless you are
desperate. Moreover you won’t be able to find the no of free addresses this way.

b.    
assume that the client has admin privilege to the dhcp server

[AntoAMJ]:
If the client has admin/user priveldge to configure the DHCP server, then the
best way to find out the number of additional leases (free addresses) in a
given scope in a given DHCP server is throught the netsh command netsh dhcp
server show mibinfo. This command will print the number of available leases for
every scope in the DHCP server.

2)   
from a client side, I would like to release a lease (or delete the
client’s lease)

a.    
assume that the client doesn’t have admin privilege to the DHCP server

[AntoAMJ]: The client does not need admin priviledge to the
DHCP server to release its own lease. All it needs to do is call the ipconfig
/release.

 

b.    
assume that the client has admin privilege to the dhcp server

 [AntoAMJ]: The client does not need admin priviledge
to the DHCP server to release its own lease. All it needs to do is call the
ipconfig /release.

 

 

 

3)   
from a client side, delete a lease on the dhcp server that the client
doesn’t own

a.    
assume that the client doesn’t have admin privilege to the DHCP server

[AntoAMJ]: Send the DHCP RELEASE packet on behalf of the
client. Create your own release packet with the MAC address of the client whose
lease has to be deleted. This is also a hack. Don’t do this unless you are
desperate.

 

b.    
assume that the client has admin privilege to the dhcp server

[AntoAMJ]: The best bet for you is call the netsh command
netsh dhcp server delete lease.

 

 

4)   
from a client side, discover if there is a dhcp server on the subnet

[AntoAMJ]:
Send a DISCOVER and wait for OFFERS to come. If there are any DHCP server which
are servincing the subnet, then that many OFFER’s will come to the client. In
fact if I remember correctly, there was a tool called dhcploc.exe which does
this automatically for you.

DhcpLoc.exe
Documentation: http://technet2.microsoft.com/WindowsServer/en/Library/8fa42e83-ec08-4a9b-9057-8909f7ed433e1033.mspx

DhcpLoc.exe
Download: http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en





 


Comments (0)