import ipaddress
import socket


def ip_address_to_bytes(ip_address: ipaddress.IPv4Address) -> bytes:
    """Convert a IP address object into bytes."""
    try:
        return socket.inet_pton(socket.AF_INET, str(ip_address))
    except OSError:
        return bytes(4)