Dax, by far, the best solutions for your issue are related to the use of the combination of the client's (IP address and subnetmask). The logical subnet on which a client is located is determined by the bitwise "AND" of each octet of the IP and MASK.
So:
IP = 123.12.45.100
MASK = 255.255.255.128
Logical subnet is calculated by performing bitwise operations:
123 & 255 = 123
12 & 255 = 12
45 & 255 = 45
100 & 128 = 0
123.12.45.0 is the logical subnet. Clients with IP addresses 123.12.45.1-127 are located on this subnet based on the mask. Clients 123.12.45.129-254 are located on subnet 123.12.45.128 if they all have a subnet mask listed above.
To find your logical subnets use this UDF and script. Supply some of your clients IP and masks and checkout the result. code:
$IP = "x.x.x.x"
$SNmask = "y.y.y.y"
? CalcLogicalSubnet ($IP, $SNmask)
Function CalcLogicalSubnet ($IP, $SNmask)
; Version 2.0
; This function calculates the logical subnet for a given IP address and subnet mask.
; The $IP parameter can be padded with spaces as from @IPADDRESS0 or without
; as from EnumIPinfo().
;
; Sets two exit codes that are passed to @Error
; 1 = Improperly formatted IP address
; 2 = Octet out range (0-255)
dim $IP, $SNmask
dim $i ;Counter for looping through 4 octets of the IP and subnet mask
dim $arrayIP ;Holds the string representation of the IP address octets.
dim $arraySN ;Holds the string representation of the subnet mask octet.
dim $Subnet ;Holds the string that becomes the logical subnet.
dim $x, $y ;Holds value of IP and SNmask octet.
$arrayIP = split($IP, ".")
$arraySN = split($SNmask, ".")
If UBound($arrayIP) = 3 and UBound($arraySN) = 3
For $i=0 to 3
$x = Val(LTrim($arrayIP[$i]))
$y = Val(LTrim($arraySN[$i]))
If $x >= 0 and $x < 256 and $y >= 0 and $y < 256
$Subnet = "" + $Subnet + ($x & $y) + "."
Else
Exit(2)
Endif
Next
$CalcLogicalSubnet = substr($Subnet, 1, len($Subnet)-1)
Exit(0)
Else
Exit(1)
Endif
Endfunction
You then could do something like: code:
if "your logical subnet" = CalcLogicalSubnet ($IP, $SNmask)
do something...
endif