Jeff,
I modified the script to print all adapters with a IPv4 IP address in case there i more than one.
I also made your change from 254 to 200 for the recommended address.
You probably want to use something like 'Gratuitous ARP'. It is used by Windows and other OSes to detect duplicate IP assignments. It is much more reliable than ICMP ping since ARP is required for TCP/IP to work within the local subnet (assuming you aren't going through a VPN or some other routed network). Firewalls cannot block it since that would prevent TCP/IP from working.
For your case, you can probably just ran an ARP scan. Since it's not super simple to send out ARP requests, simply attempt to connect to the IP you are scanning (send a UDP packet, ICMP ping, etc) and then look at your ARP table. You can look at the table in Windows by using 'arp -a' in cmd. Valid IPs will have a IP <-> MAC address mapping shown in the arp table.
Any reason you can't use a completely MS-DOS batch file to parse the info you need?
@echo off
setlocal EnableDelayedExpansion
ipconfig /all > temp1.txt
find "IP Address" temp1.txt > temp2.txt
del temp1.txt
for /F "tokens=15 delims= " %%A in ('type temp2.txt') DO @echo %%A >> temp1.txt
for /F "tokens=1,2,3,4 delims=." %%A in ('type temp1.txt') DO (
set /a var=100
if %%A geq 100 set /a var=200
@echo Recommended IP : %%A.%%B.%%C.!var!)
del temp1.txt
del temp2.txt
The above doesn't do any checking of existing connections, but that could be done by parsing the output of netstat -r to determine existing connections, and then enumerate from there.
Beau,
Neither IPCONFIG or NETSTAT will provide the WAN IPaddress and the batch file lists weird results if any IPv6 addresses are found
Output on my PC:
Recommended IP : 192.168.1.200
...200mended IP : fe80::21d:92ff:fe71:adf6%4
...200mended IP : fe80::ffff:ffff:fffd%5
Recommended IP : fe80::5efe:192.168.1.200
"Neither IPCONFIG or NETSTAT will provide the WAN IPaddress" - No but it seems as though the information Jeff is after can be extracted from NETSTAT with the -R option
"...and the batch file lists weird results if any IPv6 addresses are found" - Stricter parsing of the text file should fix that.
Jeff DOES want the WAN address - he just referred to it as "the Outside address".
Why try to use cryptic batch file commands and temp files to parse data? After all, VBScript basic (even though it is not PBasic ) is easier to follow and modify.
Comments
I modified the script to print all adapters with a IPv4 IP address in case there i more than one.
I also made your change from 254 to 200 for the recommended address.
- Ron
http://wiki.wireshark.org/Gratuitous_ARP
http://support.microsoft.com/kb/120599
For your case, you can probably just ran an ARP scan. Since it's not super simple to send out ARP requests, simply attempt to connect to the IP you are scanning (send a UDP packet, ICMP ping, etc) and then look at your ARP table. You can look at the table in Windows by using 'arp -a' in cmd. Valid IPs will have a IP <-> MAC address mapping shown in the arp table.
The above doesn't do any checking of existing connections, but that could be done by parsing the output of netstat -r to determine existing connections, and then enumerate from there.
Neither IPCONFIG or NETSTAT will provide the WAN IPaddress and the batch file lists weird results if any IPv6 addresses are found
Output on my PC:
Recommended IP : 192.168.1.200
...200mended IP : fe80::21d:92ff:fe71:adf6%4
...200mended IP : fe80::ffff:ffff:fffd%5
Recommended IP : fe80::5efe:192.168.1.200
"...and the batch file lists weird results if any IPv6 addresses are found" - Stricter parsing of the text file should fix that.
Jeff DOES want the WAN address - he just referred to it as "the Outside address".
Why try to use cryptic batch file commands and temp files to parse data? After all, VBScript basic (even though it is not PBasic
But, to each their own...
LocalNetworkInfo.zip
Thanks Mike,
Yeah those pesky jobs sure can really take up a lot of your valuable time!
I need to delve more into .Net more but learning SPIN and PASM is more enticing!
- Ron