import socket


def ip_to_bytes(addr):
    """
    Convert an IPv4 address from dotted-quad string format to 32-bit packed
    binary format,as a string four characters in length.
    """
    return socket.inet_aton(addr)