Search for the IsInSubnet UDF in the UDFs section.

I use this with a table of subnets and my GetNetInfo UDF to do exactly what you are looking for. I'll post GetNetInfo here for your convenience, and post it to the UDF section tonight when I can properly format it.

Basically, GetNetInfo loads an INF file into an array, which provides subnet and other data. The file looks something like this:
Code:

10.0.0.0/24 Info_1 Info_2 Info_3
10.0.0.0/24 Info_1 Info_2 Info_3


Info_1 might be the short Site ID, Info_2 the primary software deployment server name, and Info_3 the long description for the site, just as an example. Make sure you delimit the file with Tabs, and that all lines have the same number of fields. I maintain it in an Excel spreadsheet, and then just select the data, copy it, and paste it into Notepad.

The GetNetInfo udf works like this -
Code:
GetNetInfo(ip_address [, FieldID] [, FilePath])


It reads the file - either from a default location or the one specified. It uses the IsInSubnet UDF to compare the target IP to the array of subnets, and returns the data from the corresponding record field that you specify. Thus, if the third column of your config file contained site names, you could use
Code:

$SiteName = GetNetInfo(Ping($Host), 3, '@SCRIPTDIR\netinfo.inf')



Glenn

GetNetInfo UDF follows:

Code:
 
;;
;;======================================================================
;;
;;FUNCTION GetNetInfo()
;;
;;ACTION Returns data by matching an IP address to a subnet list
;;
;;AUTHOR Glenn Barnas
;;
;;AUTHOR Version 2.0
;;
;;SYNTAX GetNetInfo(IP_Addr [, Field] [, File])
;;
;;PARAMETERS IP_Addr - an IP address of the local server
;;
;; Field (Optional) - Field in subnets.inf to return
;; The default is field 2 - Site Name
;;
;; File (optional) - Defines the location of the subnets.inf file
;; The default is %S_CONFIG%\subnets.inf
;;
;;REMARKS Allows an application to determine physical site-specific
;; information based on the target system's IP address.
;;
;;RETURNS The data in the specified or default field of the data file
;;
;;DEPENDENCIES IsInSubnet() UDF (SeaLeopard)
;; Subnets.inf file
;; In our application, the format of this file is:
;; 192.168.0.0/23 Local_SD_Server SiteName Description
;; ALL RECORDS MUST CONTAIN THE SAME NUMBER OF FIELDS!
;;
;; The first field must be the network address & subnet - all
;; other fields are application dependent, and any number of fields
;; can be supported.
;;
;; The file is found by default in the %S_CONFIG% folder. If it is not there,
;; the @SCRIPTDIR folder is checked. If the optional File value is specified,
;; the named file is read and no other locations are checked.
;;
;;
;;TESTED WITH NT4, W2K, WXP
;;
;;EXAMPLES
;;
;;UPDATES V1.2 - 02/01/04 - Check alternate location for config file
;; v2.0 - 11/02/06 - Combine GetWANSite and GetNetInfo functionality
;
Function GetNetInfo($_IP_Addr, OPTIONAL $_Field, OPTIONAL $_File)

Dim $_, $_Idx, $_FH, $_Line, $_CFile
Dim $_aZones[500], $_aData[500], $_aTmp, $_aFound


; Insure that the Field var is a non-zero numeric value - default is 2
$_Field = IIf(Val($_Field) = 0, 2, Val($_Field))

; If $_File was specified, verify the file exists. Exit with File Not Found if it doesnt.
; otherwise, check for the standard file in default locations
If $_File
If Exist($_File)
$_CFile = $_File
Else
Exit 2 ; file not found!
EndIf
Else
; Subnet definition file should be in a std location, but could be in SCRIPTDIR
; for other installations - accept SCRIPTDIR only if not in std location
Select
Case Exist('%S_CONFIG%\Subnets.inf')
$_CFile = '%S_CONFIG%\Subnets.inf'

Case Exist('@SCRIPTDIR\Subnets.inf')
$_CFile = '@SCRIPTDIR\Subnets.inf'

Case 1
; FILE NOT FOUND
Exit 2 ; exit if file was not found

EndSelect

EndIf ; File

; the subnet definition file exists - load it into a pair of arrays
$_Idx = 0
$_FH = FreeFileHandle()
If Open($_FH, $_CFile, 2) = 0
$_Line = ReadLine($_FH)
While @ERROR = 0
$_aTmp = Split($_Line, Chr(9)) ; split the line into subnet and data
; Verify that the Field value is valid
If $_Field > UBound($_aTmp)
Exit 87 ; invalid argument was specified
EndIF

$_aZones[$_Idx] = $_aTmp[0] ; build the subnet array
$_aData[$_Idx] = $_aTmp[$_Field] ; build the data array
$_Idx = $_Idx + 1
$_Line = ReadLine($_FH) ; read the next line
Loop
EndIf
$_ = Close($_FH) ; close the file

ReDim Preserve $_aZones[$_Idx - 1] ; reduce the array sizes
ReDim Preserve $_aData[$_Idx - 1]


; see if the IP address given exists in any of the defined subnets
; This function returns an array - one element will be TRUE, corresponding
; to the array position of the matching subnet
$_aFound = IsInSubnet($_IP_Addr, $_aZones)


; search the returned array for a '1' value. If found, a corresponding
; server name should be defined in the servers array.
$_Idx = AScan($_aFound, 1)


; return the associated data if a match was found.
If $_Idx <> -1
$GetWANSite = $_aData[$_Idx]
Exit 0
EndIF


; exit with error and no data if not found
Exit 1

EndFunction