bimini07 Posted February 20, 2008 Share Posted February 20, 2008 Hi Gurus, Whenever a DHCP client can't get an IP address from a DHCP server it resolves to a 169.XXX.XXX.XXX ip address. Is it possible to write a script that detects the current ip address assigned, and if it is an APIPA ip.. then it issues an ipconfig /renew and if not then it exits. Can this also be set on a timer or as a service so every 30 secs or so the script autoruns? How would I go about doing this? Using netsh to get current stats? But how would I go about scripting on the basis of the first octet being 169 or not? I guess I am looking for some direction here.... Thanks, Link to comment Share on other sites More sharing options...
evilertoaster Posted February 20, 2008 Share Posted February 20, 2008 (edited) This should give you and idea of how to do most of what you're looking for- AdlibEnable("CheckIP",30000) While 1 Sleep(1000) Wend func CheckIP() if (StringMid(@IPAddress1,1,4)="169.") then Run(@ComSpec & " /c " & 'ipconfig /renew', "", @SW_HIDE) EndFunc Edited February 20, 2008 by evilertoaster Link to comment Share on other sites More sharing options...
bimini07 Posted February 21, 2008 Author Share Posted February 21, 2008 This should give you and idea of how to do most of what you're looking for- AdlibEnable("CheckIP",30000) While 1 Sleep(1000) Wend func CheckIP() if (StringMid(@IPAddress1,1,4)="169.") then Run(@ComSpec & " /c " & 'ipconfig /renew', "", @SW_HIDE) EndFunc Thank You! Link to comment Share on other sites More sharing options...
Gigglestick Posted February 21, 2008 Share Posted February 21, 2008 So you know, APIPA continues to search for a DHCP server every five minutes after it begins using it's auto-configured IP. You don't need this script unless that five minute interval is too large, and I'm sure you could use a registry setting to modify it if you wanted. My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
bimini07 Posted February 21, 2008 Author Share Posted February 21, 2008 So you know, APIPA continues to search for a DHCP server every five minutes after it begins using it's auto-configured IP. You don't need this script unless that five minute interval is too large, and I'm sure you could use a registry setting to modify it if you wanted.Yes... 5 Minutes is kinda too long in our environment. These systems need to have an above 99% uptime. We have a realtime monitor that tells us that such and such machine is not connected. Since it does not lease the IP address from the DHCP server... we can't get in. I would love to know the registry setting that I can tweak to achieve the same results.I have searched on increasing the dhcp renew timeout value with no success.Thanks, Link to comment Share on other sites More sharing options...
Gigglestick Posted February 21, 2008 Share Posted February 21, 2008 (edited) Yes... 5 Minutes is kinda too long in our environment. These systems need to have an above 99% uptime. We have a realtime monitor that tells us that such and such machine is not connected. Since it does not lease the IP address from the DHCP server... we can't get in. I would love to know the registry setting that I can tweak to achieve the same results.I have searched on increasing the dhcp renew timeout value with no success.Thanks,So the question is, if these systems are critical, why are they using dynamic IPs? If one's a server version of Windows, set a static IP and install DHCP on it.How to use automatic TCP/IP addressing without a DHCP serverhttp://support.microsoft.com/kb/220874/en-us Edited February 21, 2008 by c0deWorm My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now