def add_dns(ip, interface='Local Area Connection', index=1):
 servers = get_dns_servers(interface)
 if (servers is False):
  return False
 try:
  if (servers[(index - 1)] == ip):
   return True
 except IndexError:
  pass
 if (ip in servers):
  rm_dns(ip, interface)
 cmd = ['netsh', 'interface', 'ip', 'add', 'dns', interface, ip, 'index={0}'.format(index), 'validate=no']
 return (__salt__['cmd.retcode'](cmd, python_shell=False) == 0)

def add_dns ( ip , interface = 'Local Area Connection' , index = 1 ) : servers = get_dns_servers ( interface ) if ( servers is False ) : return False try : if ( servers [ ( index - 1 ) ] == ip ) : return True except IndexError : pass if ( ip in servers ) : rm_dns ( ip , interface ) cmd = [ 'netsh' , 'interface' , 'ip' , 'add' , 'dns' , interface , ip , 'index={0}' . format ( index ) , 'validate=no' ] return ( __salt__ [ 'cmd.retcode' ] ( cmd , python_shell = False ) == 0 )
add the dns server to the network interface note: if the interface dns is configured by dhcp .