def is_ipv4(hosts):
    """
    Function to validate IPv4 Addresses
    :param hosts: Takes a single host or subnet (ex. 127.0.0.1/24)
    :return: Boolean True or False
    """
    hosts = hosts.strip()
    if "/" not in hosts:
        # Assume that if no mask is specified, use a single host mask
        hosts = hosts + "/32"
    # Check if there are 4 octets and a cidr mask
    if hosts.count(".") == 3:
        # Check if the octets are no more than 255
        mask = int(hosts.split("/")[-1])
        octets = hosts.split("/")[0].split(".")
        for octet in octets:
            octet = int(octet)
            if octet <= 255:
                if mask <= 32:
                    # OK!
                    pass
                else:
                    return False
            else:
                return False
        return True
    else:
        return False