Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a DHCP server running on Windows 2003 Server. I'd like to query the lease database to find details on a lease for a specific IP. How do I do this remotely from Linux?

There is this command on windows xp:

netsh dhcp server <type.srvIP.here> scope s.s.s.s show client | find "clientIP" 

10.1.1.100      - 255.255.255.0  -10-12-34-56-78-9a   - NEVER EXPIRES        -D

I seek correspondence between the IP / MAC address with a lease on a windows dhcp server 2003.

share|improve this question
3  
You'd probably get more answers from linux/bsd folks if you described what the expected result is. –  freiheit Sep 29 '09 at 18:35
    
What you've written is still very confusing. I'll take a stab at interpreting it. Can I rephrase your question as "I have a DHCP server running on Windows 2003 Server. I'd like to query the lease database to find details on a lease for a specific IP. How do I do this remotely from Linux?" –  MikeyB Sep 29 '09 at 20:34
    
Downvoted because the question is very poorly put. –  GodEater Sep 30 '09 at 6:51
    
Thanks MikeyB i'll change my question by yours. –  AdrienF Sep 30 '09 at 13:32

4 Answers 4

up vote 5 down vote accepted

Why not try Winexe? It grants you Windows console access from Unix-like system.

share|improve this answer
    
After a quick test of winexe, this looks like exactly what I want. Thanks a lot. –  AdrienF Sep 30 '09 at 19:57

I don't believe there is a tool to do this remotely for *nix platform. Most docs will tell you to read the dhcpd.leases file directly on the server and glean the information you want from there manually. You could always write a perl (or other similar) script to do this, but I have yet to find one readily available.

share|improve this answer
    
I don't want to read lease on a *nix dhcpd server but on a windows 2003 dhcp server –  AdrienF Sep 29 '09 at 19:30

Whatever O/S the DHCP server is, the lease must be stored on the dhcp client, even if only to know when the lease must be renewed. Where the lease is stored depends of you dhcp client and your O/S.

On OpenBSD the lease history is stored in /var/db/dhclient.lease.interfacename. To see it, you can use 'cat' & tail (to display only the last lease):

benoit@alix [/var/db] sudo cat dhclient.leases.vr2 | tail -14
Password:
lease {
  interface "vr2";
  fixed-address nnn.nnn.nnn.nnn;
  server-name "dhcp.server.fqdn";
  option subnet-mask nnn.nnn.nnn.nnn;
  option routers nnn.nnn.nnn.nnn;
  option broadcast-address nnn.nnn.nnn.nnn;
  option dhcp-lease-time 604800;
  option dhcp-message-type 5;
  option dhcp-server-identifier nnn.nnn.nnn.nnn;
  renew 3 2009/9/30 08:39:39;
  rebind 5 2009/10/2 23:39:39;
  expire 6 2009/10/3 20:39:39;
}

Have a look at the manual pages of your O/S or of the dhcp client running on your box, it must contains this information.

share|improve this answer
    
Thank you for your reply, but I try to browse remotely, from a *nix client, the lease of a Windows 2003 DHCP server. –  AdrienF Sep 29 '09 at 20:00
    
Okay. It won't be really easy. netsh is specific to windows computers and I don't think you have a tool on unix that allows you to run netsh (or wmi) querries. On windows, the leases of the dhcpd server are stored in a access database, stored by default in %system32%\dhcp. Maybe you could use SNMP or try to play with the DHCP server logs (always stored in %system32%\dhcp by default).. Why can't you use the windows tools? –  Benoit Sep 29 '09 at 20:18
    
I would add a feature on my network management server, and this server is a freebsd. –  AdrienF Sep 30 '09 at 17:25
    
Is it possible to relocate the DHCP on a unix box? –  Benoit Oct 1 '09 at 14:52

I don't want to read lease on a *nix dhcpd server but on a windows 2003 dhcp server

Have you considered simply setting up an SSH server on your Windows box? Once that is installed all you would have to do is simply ssh and run netsh.

I can't install anything on my windows box because it's my domain controller.

Then you are probably out of luck.

About the only other thing I can think of is to simply ask the windows admins to setup a script that uses 'netsh' to dump the dhcp database periodically to a file that you can view.

share|improve this answer
    
I rephrase my question following your comments –  AdrienF Sep 30 '09 at 13:49
    
I can't install anything on my windows box because it's my domain controller and windows admins don't allow to add component on this server. –  AdrienF Sep 30 '09 at 17:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.