def hex2ip(host_id, reverse=False):
    """Convert the hexadecimal host ID into an IP address."""
    host_id = int(host_id, 16)
    if not reverse:
        addr = "%d.%d.%d.%d" % ((host_id >> 24) & 0xFF, (host_id >> 16) & 0xFF,
                                (host_id >> 8) & 0xFF, host_id & 0xFF)
    else:
        addr = "%d.%d.%d.%d" % (host_id & 0xFF, (host_id >> 8) & 0xFF,
                                (host_id >> 16) & 0xFF, (host_id >> 24) & 0xFF)
    return addr