3

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.

AdrienF
  • 125
  • 3
  • 10
  • 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 06:51

4 Answers4

5

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

blank3
  • 2,157
  • 1
  • 15
  • 14
0

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.

SethG
  • 314
  • 1
  • 3
  • 7
0

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.

Benoit
  • 3,499
  • 1
  • 18
  • 17
  • 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 01 '09 at 14:52
0

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.

Zoredache
  • 128,755
  • 40
  • 271
  • 413