def match(mask, IP):
    splitted_IP = IP.split('.')
for index, current_range in enumerate(mask.split('.')):
    if '-' in current_range:
        mini, maxi = map(int, current_range.split('-'))
else:
    mini = maxi = int(current_range)
if not mini <= int(splitted_IP[index]) <= maxi:
    return False
return True
Python - Check if user's IP address is in a range of IP's