Link to home
Start Free TrialLog in
Avatar of rbichon
rbichon

asked on

Detect if computer on local domain is reachable

I am able to enumerate all of the computers on my domain using LDAP and wscript. Now what I would like to do is determine which ones are currently powered on/reachable over the network. I would use ping except that it does not give reliable results. For example, if one of the domain members is using DHCP, sometimes the IP address is different on the machine than it is in DNS. Any help would be most appreciated. Thanks.
Avatar of exx1976
exx1976
Flag of United States of America image

Ummm..   If the machine name and IP don't match what's in DNS, then there is no reliable way of talking to the computer, not for you, or for the domain.  I would adjust your scavenging settings...

HTH,
exx
Avatar of rbichon
rbichon

ASKER

Good idea.
"if one of the domain members is using DHCP, sometimes the IP address is different on the machine than it is in DNS."

This should never be the case in a good network design.

Avatar of rbichon

ASKER

Well, one thing that happens is that a laptop is assigned an IP address by the router and then is shutdown or removed from the network for a long period of time. Then, another computer/laptop is assigned the same IP in a later date. It seems that our DNS server does not delete the original entry for that IP when another computer takes it over. Any ideas as to why this happens? Should I avoid using the routers DHCP function and setup DHCP on our main server?
SOLUTION
Avatar of HawkTitan
HawkTitan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbichon

ASKER

I have two GC servers on my domain, both running DNS. Does it matter which one I use for DHCP?  Also, will this prevent others from obtaining an IP via DHCP who connect to the lan/wlan without being on the domain, i.e. customers, vendors, etc?
You can use either, and no, DHCP is a network protocol, like DNS.  It doesn't require authentication.  It will hand out addresses to whatever is configured for DHCP.  PCs, printers, whatever.

HTH,
exx
Quick addition, the only problem would be if the DHCP server goes down you would have a problem, so it would be good to build in redundancy with your servers or you would need to reconfigure the routers to supply DHCP in such a situation.
Or just make the DHCP lease like 7 days..  Then you have at least 3.5 days to fix it or build a new one..
For the existing computers maybe but it wouldn't help if a customer/vendor laptop came into the network.
And in those one-off situations, a static IP works quite well.

Redundant DHCP is a good idea, but it can quickly become an administrative nightmare.  If he was using a router for DHCP, I'm going to take a flyer and say that

A) there was no redundancy before

and

B) the network is probably not of a size that requires that level of complexity.


Just my $.02, YMMV.

-exx
Avatar of rbichon

ASKER

I am using the secondary DNS server to act as the DHCP server. Also, my router had three settings in regards to DHCP; 1) DHCP Enabled, 2) DHCP Disabled, 3) DHCP Relay. I am using DHCP relay and have plugged in the IP of the server that it relays to. I don't know if this is necessary, but everything switched over fine with no problems.
Now, back to my original question. I created a vbscript that queries each domain member to see if it is active and reachable by the domain. It is slow but effective.

On Error Resume Next
set sh = createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set sys32 = fso.GetSpecialFolder(1)
'********************************************************************************************************************************************

Set ObjOU = GetObject("LDAP://CN=Computers,DC=mydomain,DC=local")
For Each objMember in ObjOU.Member
	Set ObjComp = GetObject("LDAP://" & objMember)
	Set Processes = GetObject("winmgmts://" & ObjComp.CN).ExecQuery("select * from Win32_Process")
	if (err.number = 0) then
		'Server connected successfully to the remote computer
		sh.run sys32 & "\shutdown.exe /r /f /m \\" & ObjComp.CN & " /t 300 /c " & chr(34) & "Domain: System Reboot" & chr(34),0
	end if
	err.clear
Next

Open in new window

DHCP relay is only necessary if the DHCP Server will be handing out addresses to networks other than the one it is on.

For example, if the server is on 192.168.1.0/24, and the PCs are on 192.168.2.0/24, then yes, you'd have to configure your router or layer 3 switch with DHCP forwarding (called IP-Helper in Cisco gear).

Glad you got it worked out.


-exx