Shop OBEX P1 Docs P2 Docs Learn Events
Programmers: I need some help with a Windows Tool - Page 2 — Parallax Forums

Programmers: I need some help with a Windows Tool

2»

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-06 11:51
    I've adjusted it down to .200 instead of .254.
    [/QUOTE

    That is another reason why I like VBScript and Windows Scripting Host.

    It is powerful and easy to modify without expensive or extensive development tools.

    It can't make API calls and has other limitations but for many applications it is great.

    Notepad can do it!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-06 15:13
    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.

    - Ron
  • Harrison.Harrison. Posts: 484
    edited 2011-07-07 10:46
    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.

    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.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-07-07 13:14
    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.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-07 13:39
    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
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-07-07 13:49
    "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.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-07 14:33
    Beau,

    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 :smile:) is easier to follow and modify.

    But, to each their own...
  • Mike GMike G Posts: 2,702
    edited 2011-07-08 06:52
    Here's the C# code base with filtering for private IPs. Sorry it took me longer than expected, pesky job got in the way.

    LocalNetworkInfo.zip
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-08 07:01
    Mike G wrote: »
    Here's the C# case base with filtering for private IPs. Sorry it took me longer than expected, pesky job got in the way.

    Thanks Mike,
    Yeah those pesky jobs sure can really take up a lot of your valuable time! :smile:

    I need to delve more into .Net more but learning SPIN and PASM is more enticing!

    - Ron
Sign In or Register to comment.