import socket


def check_host(host):
  """Verifies host given is valid.

  Args:
      host (str): Either IP Address or hostname to verify

  Raises:
      ValueError: if ip address provided is invalid

  Returns:
      str: host
  """

  try:  # Valid ip address?
    socket.inet_pton(socket.AF_INET, host)
  except socket.error:
    try:  # Valid hostname?
      socket.getaddrinfo(host, None)
    except socket.error:
      raise ValueError("Host Address {} not valid".format(host))
  return host