def ip_to_bytes(ip_str, big_endian=True):
    """
    Converts an IP given as a string to a byte sequence
    """
    if big_endian:
        code = '>L'
    else:
        code = '<L'
    return bytes(struct.unpack(code, socket.inet_aton(ip_str))[0])
Converts an IP given as a string to a byte sequence