import ipaddress


def ip_only(value):
    """
    Returns only the IP address string of the value provided.  The value could be either an IP address,
    and IP network or and IP interface as defined by the ipaddress module.

    Parameters
    ----------
    value : str
        The value to use

    Returns
    -------
    str
        The IP address only value, if the value provided was valid

    None
        If the value provided is not an IP thing
    """
    for test in [lambda x: str(ipaddress.ip_address(x)),
                 lambda x: str(ipaddress.ip_interface(x).ip),
                 lambda x: str(ipaddress.ip_network(x).network_address)]:
        try:
            return test(value)

        except:
            pass

    return None