docs: def resolve_dns(opts, fallback=True):
      '''
      Resolves the master_ip and master_uri options
      '''
      ret = {}
      check_dns = True
      if (opts.get('file_client', 'remote') == 'local' and
              not opts.get('use_master_when_local', False)):
          check_dns = False
      # Since salt.log is imported below, salt.utils.network needs to be imported here as well
      import salt.utils.network
  
      if check_dns is True:
          try:
              if opts['master'] == '':
                  raise SaltSystemExit
              ret['master_ip'] = salt.utils.network.dns_check(
                  opts['master'],
                  int(opts['master_port']),
                  True,
                  opts['ipv6'],
                  attempt_connect=False)
          except SaltClientError:
              retry_dns_count = opts.get('retry_dns_count', None)
              if opts['retry_dns']:
                  while True:
                      if retry_dns_count is not None:
                          if retry_dns_count == 0:
                              raise SaltMasterUnresolvableError
                          retry_dns_count -= 1
                      import salt.log
                      msg = ('Master hostname: \'{0}\' not found or not responsive. '
                             'Retrying in {1} seconds').format(opts['master'], opts['retry_dns'])
                      if salt.log.setup.is_console_configured():
                          log.error(msg)
                      else:
                          print('WARNING: {0}'.format(msg))
                      time.sleep(opts['retry_dns'])
                      try:
                          ret['master_ip'] = salt.utils.network.dns_check(
                              opts['master'],
                              int(opts['master_port']),
                              True,
                              opts['ipv6'],
                              attempt_connect=False)
                          break
                      except SaltClientError:
                          pass
              else:
                  if fallback:
                      ret['master_ip'] = '127.0.0.1'
                  else:
                      raise
          except SaltSystemExit:
              unknown_str = 'unknown address'
              master = opts.get('master', unknown_str)
              if master == '':
                  master = unknown_str
              if opts.get('__role') == 'syndic':
                  err = 'Master address: \'{0}\' could not be resolved. Invalid or unresolveable address. ' \
                        'Set \'syndic_master\' value in minion config.'.format(master)
              else:
                  err = 'Master address: \'{0}\' could not be resolved. Invalid or unresolveable address. ' \
                        'Set \'master\' value in minion config.'.format(master)
              log.error(err)
              raise SaltSystemExit(code=42, msg=err)
      else:
          ret['master_ip'] = '127.0.0.1'
  
      if 'master_ip' in ret and 'master_ip' in opts:
          if ret['master_ip'] != opts['master_ip']:
              log.warning(
                  'Master ip address changed from %s to %s',
                  opts['master_ip'], ret['master_ip']
              )
      if opts['source_interface_name']:
          log.trace('Custom source interface required: %s', opts['source_interface_name'])
          interfaces = salt.utils.network.interfaces()
          log.trace('The following interfaces are available on this Minion:')
          log.trace(interfaces)
          if opts['source_interface_name'] in interfaces:
              if interfaces[opts['source_interface_name']]['up']:
                  addrs = interfaces[opts['source_interface_name']]['inet'] if not opts['ipv6'] else\
                          interfaces[opts['source_interface_name']]['inet6']
                  ret['source_ip'] = addrs[0]['address']
                  log.debug('Using %s as source IP address', ret['source_ip'])
              else:
                  log.warning('The interface %s is down so it cannot be used as source to connect to the Master',
                              opts['source_interface_name'])
          else:
              log.warning('%s is not a valid interface. Ignoring.', opts['source_interface_name'])
      elif opts['source_address']:
          ret['source_ip'] = salt.utils.network.dns_check(
              opts['source_address'],
              int(opts['source_ret_port']),
              True,
              opts['ipv6'],
              attempt_connect=False)
          log.debug('Using %s as source IP address', ret['source_ip'])
      if opts['source_ret_port']:
          ret['source_ret_port'] = int(opts['source_ret_port'])
          log.debug('Using %d as source port for the ret server', ret['source_ret_port'])
      if opts['source_publish_port']:
          ret['source_publish_port'] = int(opts['source_publish_port'])
          log.debug('Using %d as source port for the master pub', ret['source_publish_port'])
      ret['master_uri'] = 'tcp://{ip}:{port}'.format(
          ip=ret['master_ip'], port=opts['master_port'])
      log.debug('Master URI: %s', ret['master_uri'])
  
      return ret