import socket


def get_ip_address(host='1.2.3.4'):
    """Return IP from hostname or IP."""
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        sock.connect((host, 9))
        return sock.getsockname()[0]
    except socket.error:
        return None
    finally:
        del sock