import ipaddress


def is_valid_ip(ip):
    """
    Validate ip address
    :param ip: ip address
    :return: boolean
    """
    res = False
    if isinstance(ip, str):
        try:
            ipaddress.ip_address(ip)
            res = True
        except ValueError:
            res = False
    return res