
04-30-2005, 12:01 PM
|
 |
Relational DB Theorist
|
|
Join Date: Apr 2005
Posts: 33
|
|
|
Function to Check Whether IP is Private Address
Code:
Function IsPrivateIp(sIpAddress)
' Given IP string, checks whether it is a private address
' DOES NOT CHECK FOR VALID IP FORM
' Use IsValidIp to check validity
' Checks for STRICT private addresses;
' does not guess about common misuse such as 192.0 nets
Dim aTmp
IsPrivateIp = False
aTmp = split(sIpAddress,".")
' Is it a class 10 network?
If aTmp(0) = 10 Then IsPrivateIp = True
' If not a 10, is it a 172 private address?
If aTmp(0) = 172 Then
If ( aTmp(1)>15 ) And ( aTmp(1)<32 ) Then IsPrivateIp = True
End If
' If neither of the above, is it a 192.168 IP?
If ( aTmp(0)=192 ) And ( aTmp(1)=168 ) Then IsPrivateIp = True
End Function
|