Jump to content

Compare Ip To Mask


Recommended Posts

This function accepts an IP address and a mask to compare it to and returns either a o if false or a 1 if true. For the mask you can replace octets with an asterisk as a wild card. The function accepts mutltiple wildcards.


CompareIP("","10.0.0.*") = True

CompareIP("","10.0.0.*") = True

CompareIP("","10.*") = True

CompareIP("","*.*.*.2") = False

Func CompareIP($IP, $Mask)
    Local $i

    $IP = StringSplit($IP, ".")
    $Mask = StringSplit($Mask, ".")

    For $i = 1 To ubound($mask) -1
        If $Mask[$i] <> "*" Then
            If int($IP[$i]) <> int($Mask[$i]) Then Return 0
    Return 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...