• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1346
  • Last Modified:

Get the DHCP scopes (Ranges)

Hi,

I have 4 DHCP servers.I have there ip's in a file.txt.I want to get there start and end ip range as each DHCP server have many scopes.Is there any i can get the start and end ip range to a file.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 8
  • 6
  • 2
  • +1
1 Solution
 
duffman76Commented:
You can use the netsh command to dump the scopes to a file

netsh dhcp server dump all > dump.txt

That should show you the start and end of the scopes.

Hope that helps.
0
 
bsharathAuthor Commented:
I get this.


Unable to determine the DHCP Server version for the Server 129.140.120.25.
Server may not function properly.

I have many dhcp servers will it get all the scopes?
0
 
duffman76Commented:
Did you make sure that the DHCP Service is running and you are a member of the local admins group?  You will have to run the command for each server but not for every scope.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
bsharathAuthor Commented:
I tried i even ran on the DC with Domain admin credentials but get the same message....
0
 
zoofanCommented:
As duffman stated,

Qouted from
"http://www.microsoft.com/technet/community/chats/trans/windowsnet/06_0721_tn_script.mspx"

Greg Stemp (Moderator):
Q: Also, can I use scripting to query DHCP for things like, what MAC is assigned to an IP address, or when the IP was first issued, etc..??
A: (pi) I told Jean I was going to use the pizza emoticon, and by golly I did! Of course, I should have used the sad face emoticon: none of Microsoft's DHCP server stuff is exposed to scripting. The best you can do is use the command-line tool Netsh.exe. Sorry.



zf
0
 
Farhan KaziSystems EngineerCommented:
Put all DHCP server names inside the DHCPServers.txt file on C: drive root, and run following command.
This will show you DHCP Server Active Scope Info.

Click Start -> Run -> Cmd.exe
For /f %i in (C:\DHCPServers.txt) do netsh dhcp server \\%i show scope | find /i "active"
0
 
bsharathAuthor Commented:
Farhan,

I get some scopes of some machines others show this.

C:\>netsh dhcp server \\in-ads-srv02 show scope   | find /i "active"  1
File not found - 1
0
 
Farhan KaziSystems EngineerCommented:
Do you have administrative access on these machines? Are these server functional and successfully assigning IP's to client machines? Does these machines have any firewall installed?

Apply following commands and post results.

netsh dhcp server \\in-ads-srv02 show all
netsh dhcp server \\in-ads-srv02 dump
0
 
bsharathAuthor Commented:
All these are working
0
 
Farhan KaziSystems EngineerCommented:
Apply following commands and post results.

netsh dhcp server \\in-ads-srv02 show all
netsh dhcp server \\in-ads-srv02 dump
0
 
bsharathAuthor Commented:
I get this.


C:\>netsh dhcp server \\in-ads-srv02 show all

MIBCounts:
        Discovers = 8279.
        Offers = 8279.
        Requests = 294439.
        Acks = 345165.
        Naks = 155.
        Declines = 25.
        Releases = 24.
        ServerStartTime = Monday, July 16, 2007 10:37:28 PM
        Scopes = 2.
        Subnet = 129.140.184.0.
                No. of Addresses in use = 204.
                No. of free Addresses = 632.
                No. of pending offers = 0.
        Subnet = 129.140.189.0.
                No. of Addresses in use = 0.
                No. of free Addresses = 50.
                No. of pending offers = 0.


Server Database Properties :

        DatabaseName              = dhcp.mdb
        DatabasePath              = C:\WINNT\System32\dhcp
        DatabaseBackupPath        = C:\WINNT\System32\dhcp\backup
        DatabaseBackupInterval    = 60 mins.
        DatabaseLoggingFlag       = 1
        DatabaseRestoreFlag       = 0
        DatabaseCleanupInterval   = 60 mins.


Server Status:
        Server Attrib - Rogue Authorization Succeeded :TRUE
        Server Attrib - Dynamic BootP Support Enabled :TRUE
        Server Attrib - DHCP Server Part Of DS        :TRUE
        Server Attrib - DHCP Server Bindings Aware    :TRUE
        Server Attrib - Administrative Rights         :TRUE
0
 
Farhan KaziSystems EngineerCommented:
Try following command and post results:
netsh dhcp server \\in-ads-srv02 show scope
0
 
bsharathAuthor Commented:
Farhan.For this command i get the results...
0
 
Farhan KaziSystems EngineerCommented:
Results?? You mean you get not results?
0
 
bsharathAuthor Commented:
Yes Farhan.
With the script you gave in the start does not give the results which i got for your command
netsh dhcp server \\in-ads-srv02 show scope

Farhan.

Have this Q from a long time.I dont know if this is possible.
1. Is there any way to get only 1 days leases that is only today's leases.
2. Get to know only ip leases for machines which are not of my domain.This would be useful to get users details who have connected to our network(External users laptops)

0
 
Farhan KaziSystems EngineerCommented:
>> I get some scopes of some machines others show this.
Strange!!  Verify the configuration of those system that are giving your proper results and those that are misbehaving .

>> 1. Is there any way to get only 1 days leases that is only today's leases

DHCP server maintains a log files for all events,you can find the audit logs in the c:\windows\system32\dhcp folder. The log files use the name DhcpSrvLog-XXX.log, where XXX is a series of three letters that represents the day of the week that the log was created on. For example, a log named DhcpSrvLog-Fri.log would be the log file that was created on Friday.

If you look at the sample log file, you'll see that the first part of the log file contains a list of codes.
The log portion of the file is actually presented in CSV format.This means that each field is separated by a comma. CSV files can be difficult to read within a word processor. However they can be imported into Microsoft Excel for easier reading.

Copy and paste current date log file to desktop and open it in Notepad.
Delete all lines until following heading
ID,Date,Time,Description,IP Address,Host Name,MAC Address
Save log file -> Close Notepad -> Import this log to MS Excel and enable 'Auto Filter' -> Now in 'ID' column check for ID 10 and 11.
10 represents a new IP address was leased to a client and 11 represents a lease was renewed by a client.

>>2. Get to know only ip leases for machines which are not of my domain.This would be useful to get users details who have connected to our network(External users laptops)

NOT possible through DHCP, however you can I have already provided you the another trick that can work for you in this case.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22713374.html#a19546758
0
 
bsharathAuthor Commented:
Hi Farhan,

You are just a genius...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 8
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now