import socket


def is_ip_address(af, addrstr):
    """
    Check if ip address string is a valid ip address.

    :param int af: address family
    :param str addrstr: ip address string
    :return: True if a valid ip address, False otherwise
    :rtype: bool
    """
    try:
        socket.inet_pton(af, addrstr)
        return True
    except IOError:
        return False