import socket


def ipv4(value):
    """Validate an IPv4 address"""
    try:
        socket.inet_aton(value)
        if value.count(".") == 3:
            return value
    except socket.error:
        pass
    raise ValueError("{0} is not a valid ipv4 address".format(value))