delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/27/05:31:47

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=sgyiuORu/wVSqK41
4F5xJoyGfSxKihjCkoDStedNQvvnlzM6BLhnUeSFJVcftn9MwkjyrFx4RtKZnJVs
Q5Np1Di1cJXdR6PDAwY8lb4TX7uiAv9nsvbRO5tlQoaAqILmA4aCAJ77d+YUNS2y
qLnyQ/q2rjI3qTKQ+G3Xein+ZEI=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=emKn04xHO6qW7UVtiBXL/s
3sv4c=; b=HZd2kA842gaTEVNxsjhiWQ6snx6Q3p6qnGEmSI48HQstnC0fBBO2bh
63w0bMLlMg3sgLf+XnAq1JxlDChYckXRUwlTCPIgIzL10iPgmycVc0/2ibgVLeJd
ylb8gHUxJ6ykD7kHb7RqAT6enKe5leD/1jpWYKr6Ne/RDSctrZrAk=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=morning
X-HELO: mout.gmx.com
Subject: Re: Automatically populate resolv.conf when new DNS is acquired
To: cygwin AT cygwin DOT com
References: <65242f5d-cc15-0024-47a8-0ce6be81aced AT mail DOT com> <c69b1d0a-74e9-bfe0-7c7e-500499844da5 AT SystematicSw DOT ab DOT ca>
From: john doe <johndoe65534 AT mail DOT com>
Message-ID: <7b7e40f8-3f84-4080-8ffa-9ac92b973435@mail.com>
Date: Wed, 27 Jun 2018 11:31:21 +0200
MIME-Version: 1.0
In-Reply-To: <c69b1d0a-74e9-bfe0-7c7e-500499844da5@SystematicSw.ab.ca>
X-IsSubscribed: yes

Good morning  Brian, bottom posting.

On 6/26/2018 4:18 PM, Brian Inglis wrote:
> On 2018-06-26 04:33, john doe wrote:
>> In gnupg2 the use of dirmngr utility is required to interact with a keyserver.
>> Dirmngr requires that '/etc/resolv.conf' be populated with my name servers.
>> That means that everytime the dns changes (new network ...) I need to manually
>> edit that file.
>> How can I let Cygwin update that file whenever the DNS is changed?
> 
> Attached an awk script to generate resolv.conf from Windows ipconfig /all
> output, run from .cygwin_profile (sourced under Cygwin from login .bash_profile)
> using the stanza below: it only replaces an existing writable /etc/resolv.conf
> when the content changes - touch, chown, chmod /etc/resolv.conf to enable.
> 
> # update /etc/resolv.conf if changed
> c=/etc/resolv.conf
> test -w $c					&& \
> i=$(/usr/bin/which -- ipconfig)			&& \
> r=$(/usr/bin/which -- resolv.awk)		&& \
> t=$(/bin/mktemp -t -- resolv.conf.$$.XXXXXXXX)  && \
> if $i /all | $r      >  $t; then
>      /usr/bin/cmp -s -- $t $c	|| \
>      /bin/cp -fv     -- $t $c
>      /bin/rm -f	    -- $t
> fi
> 
> unset c i r t
> 
> This could be used in a bash script run from a Windows scheduled task when a
> relevant DHCP event occurs: you can find DHCP events by checking Windows Admin
> Tools/Event Viewer/Window Logs/System/Filter Current Log/Event
> Sources/Dhcp-Client,DHCPv6-Client, or a similar PowerShell script.
> 

Thanks for the awk script and the explanation on how to use it! :)

By Windows Admin you mean "Windows Admin Center"?
I'm using Cygwin on a laptop (win 7 pro) and sadly, if I'm not 
mistaking, "Windows Admin" is not available on non-server platform.

If I can't find a way to determine when my DNS changes I can clearly 
emulate an hourly cron job by using "task scheduler".

Many thanks for the task scheduler hint and for your help.

-- 
John Doe

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

- Raw text -


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