from functools import reduce


def inet_aton(s):
    """Convert a dotted-quad to an int."""
    try:
        addr = list(map(int, s.split('.')))
        addr = reduce(lambda a,b: a+b, [addr[i] << (3-i)*8 for i in range(4)])
    except (ValueError, IndexError):
        raise ValueError('illegal IP: {0}'.format(s))
    return addr