def nslookup(host):
 ret = []
 addresses = []
 cmd = ['nslookup', salt.utils.network.sanitize_host(host)]
 lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
 for line in lines:
  if addresses:
   addresses.append(line.strip())
   continue
  if line.startswith('Non-authoritative'):
   continue
  if ('Addresses' in line):
   comps = line.split(':', 1)
   addresses.append(comps[1].strip())
   continue
  if (':' in line):
   comps = line.split(':', 1)
   ret.append({comps[0].strip(): comps[1].strip()})
 if addresses:
  ret.append({'Addresses': addresses})
 return ret

def nslookup ( host ) : ret = [ ] addresses = [ ] cmd = [ 'nslookup' , salt . utils . network . sanitize_host ( host ) ] lines = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) . splitlines ( ) for line in lines : if addresses : addresses . append ( line . strip ( ) ) continue if line . startswith ( 'Non-authoritative' ) : continue if ( 'Addresses' in line ) : comps = line . split ( ':' , 1 ) addresses . append ( comps [ 1 ] . strip ( ) ) continue if ( ':' in line ) : comps = line . split ( ':' , 1 ) ret . append ( { comps [ 0 ] . strip ( ) : comps [ 1 ] . strip ( ) } ) if addresses : ret . append ( { 'Addresses' : addresses } ) return ret
query dns for information about a domain or ip address cli example: .