Programmers: I need some help with a Windows Tool

Guys,
There is a LOT of programming talent here, and I need your help.
I need a Windows tool that does the following...
Checks your LAN and returns the following information (In a window)
Recommended IP address: 192.168.1.X
(Please use the follow criteria to determine the recommended address:
* Check the workstation's address.
If it is in the 10's make X a number around 100
If it is in the 100's make X a number around 200
Check to see if the address is already alive, move forward if it is.)
The idea here is to find an open number, away from other IPs on the lan.
Report the Subnet Mask (255.255.255.0 -- yada yada)
Report the Gateway
Report the Outside IP address (The one that is live to the Internet)
The window should have four pieces of information:
Recommended IP
Subnet Mask
Current Gateway
Outside "live" IP Address
I can't promise any riches for this, but I will put your name in "lights" in the credits of material I'm creating for the Spinneret.
Thanks
OBC
There is a LOT of programming talent here, and I need your help.
I need a Windows tool that does the following...
Checks your LAN and returns the following information (In a window)
Recommended IP address: 192.168.1.X
(Please use the follow criteria to determine the recommended address:
* Check the workstation's address.
If it is in the 10's make X a number around 100
If it is in the 100's make X a number around 200
Check to see if the address is already alive, move forward if it is.)
The idea here is to find an open number, away from other IPs on the lan.
Report the Subnet Mask (255.255.255.0 -- yada yada)
Report the Gateway
Report the Outside IP address (The one that is live to the Internet)
The window should have four pieces of information:
Recommended IP
Subnet Mask
Current Gateway
Outside "live" IP Address
I can't promise any riches for this, but I will put your name in "lights" in the credits of material I'm creating for the Spinneret.
Thanks
OBC
Comments
Dynamic Host Configuration Protocol ( DHCP) inthe router handles assigning IP addresses, unless they are manually
assigned or the router allows DHCP Reservation.
I use DHCP Reservation to make sure that IP addresses remain constant without manually assigining them (see image).
The only method I can envision that might work is a kludge - basically displaying HTML IP status pages from your particular router in a browser object and then parsing the web page using the Document Object Model (DOM) to extract the addresses. This method would be specific to your router (and firmware version).
Extracting data in this fashion is sometimes called "screen scraping" or "web scraping" http://en.wikipedia.org/wiki/Web_scraping
Should be able to make a determination from that address which are being used.. If it's in the 10's then the safety region is around 100. If it's in the 100's then the safety region should be around 200. A simple PING should be able to confirm the address is likely unused.
OBC
IP addresses don't have to be assigned sequentially so there is no way "to determine" what ranges are in use (or reserved). A PING is not a reliable way since many security programs block PING requests to prevent hacker attacks.
- Ron
PS There are other reserved Private IP addresses (as specified by the Internet Assigned Numbers Authority (IANA)) you might be able to use besides 192.168.0.0 – 192.168.255.255.
They are:
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
Home networking routers typically hand out addresses starting either in the 10's or 100's. I know there is no exact way to determine an address, but we can take some reasonable "guesses" for home users based on the workstation's IP address. Anyone using the device on a larger network should contact their network administrator to make sure they don't cause a problem.
In my experience home routers generally don't hand out more than a few addresses given most of us don't have more than a handful of devices.
OBC
The other displays your WAN IP Address by using an HTTPRequest to browse to http://checkip.dyndns.org/ to get your WAN (Wide Area Network) address which is what I think you are calling the "Outside IP address".
Copy this code into notepad and save them as WANIP.vbs and GetIP.vbs and double click them to run.
This may get you started...
WANIP.vbs
GetIP.vbs
Ah ha! Yes.. This is going the direction we need. Getting an error in GetIP.vbs though..
OBC
GetIP.vbs
Windows Script Host
Script: C:\GetIP.vbs
Line: 8
Char: 1
Error: 0x80041013
Code: 80041013
Source: (null)
OBC
Try running "IPCONFIG /ALL>C:\Jeff.txt" from a DOS prompt. This will create C:\Jeff.txt with the IPConfig output. Open Jeff.txt with notepad and post the results...
Try running this version - the WHERE clause is commented out.
Does it display 192.168.2.8?
Since your IPConfig output looks simple and straightforward, I am stumped.
Run it from the command line.
We're getting closer..
OBC
That's the ticket!
Now we just need to make an "educated" guess as to an available IP outside of the typical address ranges..
OBC
it replaces the last node with 254 for a recommended address
e.g. 192.168.1.100 --> 192.168.1.254
This is rather a crude way to do this. A compiled program doing API calls would be better - especially since the WMI approach did not work for you...
Also you might have multiple adapters.
Not bad.. Can you slip the Gateway and Outside IP into this single script?
OBC
Here you go!
The bill is on the way - I don't take PAYPAL
- Ron
If you have Microsoft TCP/IP version 6 installed, it complicates the IPCONFIG results, but the script handles it.
e.g.
http://forums.parallax.com/attachment.php?attachmentid=82686&d=1309959165
and if you can how do you do it
I am not trying to hijack this post
Mike, it looks like you wrote this in Visual Studio 2010 .NET so I am curious, why does it need to run from a command line?
Maybe it would appeal more to Jeff if it displayed in a window.
I haven't done much with dotnet - I still use VB6 alot - old habits are to break.
I don't think these suggested addresses from your program are legitimate
Suggested IP(s) ............... : 254.128.0.10
Suggested IP(s) ............... : 254.128.0.10
Suggested IP(s) ............... : 254.128.0.10
Suggested IP(s) ............... : 0.0.0.10
Suggested IP(s) ............... : 254.128.0.10
Could you post the source code?
Does this script also work successfully on Windows 7?
OBC
Don't know - maybe someone can try it and let us know.
I am still a big fan of XP Pro. VISTA was terrible but Windows 7 sounds good - but I am afraid that some development tools I still use may not work under WIN7.
There are still a LOT of XP users out there...
It doesn't really... I did not put in a pause so when the program completes the console goes away. That's an easy thing to fix... lazy I guess. I'll post the source when I get home from work.
I simply executed the logic given by OBC's requirements. I can easily filter out the x.x.x.0 IPs.
It is in a window? do you mean a Win form?
The only valid Private IP addresses according to the IANA are:
192.168.0.0 192.168.255.255.
10.0.0.0 10.255.255.255
172.16.0.0 172.31.255.255
I can add IP filtering to a config file so that way thte user can restrict the results. Plus I will not allow redundant entries or adapters that are not "UP".
Ron, fyi, I'm getting a recommend IP of 170.68.14.254 but I'm at work.
I've seen some printer installs want that address.
OBC