delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/01/04/12:02:15

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 4 Jan 2005 12:04:42 -0500
From: "Pierre A. Humblet" <pierre DOT humblet AT ieee DOT org>
To: cygwin AT cygwin DOT com
Cc: Olaf DOT Foellinger AT sesa DOT net
Subject: Re: How to deal with DHCP and DNS(-tools)?
Message-ID: <20050104170442.GA470657@Worldnet>
References: <20050103205224 DOT GA2696 AT sesa DOT net>
Mime-Version: 1.0
In-Reply-To: <20050103205224.GA2696@sesa.net>
User-Agent: Mutt/1.4.1i

On Mon, Jan 03, 2005 at 09:52:24PM +0100, Olaf F?llinger wrote:
> Hi,
> 
> on my notebook with WinXP I'm using cygwin day by day. I receive the ip
> configuration by dhcp from windows. While most of the cygwins tools have
> no problem the dns tools(host, dig,...) seems to insist on a working
> /etc/resolv.conf. Does anyone have a automatic solution for updating
> this file with the current settings?
  
You could write a program using minires. It should call
res_init to initialize the _res structure and then
print the fields to /etc/resolv.conf, as sketched below.

Note that if /etc/resolv.conf exists, then minires will use it
in preference to the Windows values. Thus /etc/resolv must be
renamed in your program.

Also /etc/resolv.conf will affect applications using minires.
On Win2000 and XP they will call the nameservers specified in
/etc/resolv.conf instead of using the native Windows resolver,
except if the "options" line in /etc/resolv.conf contains the
"osquery" keyword.

Pierre

#include <stdio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <resolv.h>

main()
{
   FILE *fd;
   int i;

   rename (_PATH_RESCONF, _PATH_RESCONF ".bak");
   fd = fopen (_PATH_RESCONF, "wb");	
   _res.options |= RES_DEBUG; So you can see what happens
   res_init ();
   /* Print domain name */
   if (_res.defdname[0])
     fprintf (fd, "domain %s", _res.defdname);
   /* Print search list */
   for (i=0; _res.dnsrch[i]; i++)
      fprintf(fd, ..., _res.dnsrch[i]);
   /* Print name server addresses */
   for (i=0; i < _res.nscount; i++)
     fprintf (fd, ..., _res.nsaddr_list[i]...);
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019