Page 1 of 1 1
Topic Options
#119018 - 2004-05-04 08:40 PM Checking for host not configured for DHCP
Dave Offline
Lurker

Registered: 2004-05-04
Posts: 2
Hi,
Does anyone have a suggestion how I could use Kixtart to find all hosts on my network not using DHCP?

Thanks
Dave

Top
#119019 - 2004-05-05 02:58 AM Re: Checking for host not configured for DHCP
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja.
take your ip-range (say, mask 255.255.255.0 and addies 192.168.129.x)
Code:

for $numba=1 to 254
if not checkdhcp("192.168.129."+$numba)
"ip 192.168.129."+$numba+" has no DHCP enabled" ?
endif
next

function checkDHCP($ip)
dim $card,$int,$,$sk,$cardkey
$int="\\"+$ip+"\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
$card="\\"+$ip+"\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"
$=0
$sk=enumkey($card,$)
while @error=0
$=$+1
$cardkey=$int+"\"+readvalue($card+"\"+$sk,"ServiceName")
if readvalue($cardkey,"EnableDHCP")
$checkDHCP=1
endif
$sk=enumkey($card,$)
loop
endfunction




[note]
(post de 12000 )
[/note]
_________________________
!

download KiXnet

Top
#119020 - 2004-05-06 03:16 PM Re: Checking for host not configured for DHCP
Dave Offline
Lurker

Registered: 2004-05-04
Posts: 2
This is great! Thanks for your help, it got me going and now the I've been able to add the script below to check each user when they logon to determine who is on my network with a static address.
Thanks again.
Dave


dim $card,$int,$,$sk,$cardkey,$checkDHCP,$INFIP

$int="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
$card="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"
$=0
$sk=enumkey($card,$)

while @error=0

$=$+1
$cardkey = $int+"\"+readvalue($card+"\"+$sk,"ServiceName")
$checkDHCP = Readvalue($cardkey,"EnableDHCP")
$INFIP= Readvalue($cardkey,"IPAddress")
$IPCompare=LEFT($INFIP,3)

IF $checkDHCP=0 AND $IPCompare="10."

IF OPEN(1, "\\LVOTT244\FIXME\DHCPCHECK.txt",3) = 0

$text = ReadLine(1)

While @ERROR = 0
$text = $text + ReadLine(1)
Loop

CLOSE(1)

IF INSTR(UCASE($TEXT),@HOSTNAME) = 0

IF OPEN(1, "\\LVOTT244\FIXME\DHCPCHECK.txt",4) = 0
;$hostname = $text + CHR(13) + CHR(10) + @HOSTNAME + " " + @FULLNAME + CHR(13) +CHR(10)
$hostname = @HOSTNAME + " " + @FULLNAME + " " + @IPADDRESS0 +CHR(13) +CHR(10)
WRITELINE(1,$hostname)
CLOSE(1)
;? "File contents: " + $hostname

else
;? "Error opening file: \\LVOTT244\FIXME\DHCPCHECK.txt for writing"
;? "Error Code: " + @ERROR + " - " + @SERROR

ENDIF
ENDIF

ELSE
;? "Error opening file: \\LVOTT244\FIXME\DHCPCHECK.txt for reading"
;? "Error Code: " + @ERROR + " - " + @SERROR

ENDIF

ENDIF

$sk=enumkey($card,$)

loop




Edited by Dave (2004-05-06 03:17 PM)

Top
#119021 - 2004-05-06 04:02 PM Re: Checking for host not configured for DHCP
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh, I see you didn't like my UDF

but glad I could help.
keep on kixing
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.055 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org