From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114843 invoked by alias); 26 Jun 2018 14:18:58 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 113702 invoked by uid 89); 26 Jun 2018 14:18:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Window, Admin, nf, H*UA:WOW64 X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 14:18:55 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with ESMTP id Xoo0fLW2f8PStXoo1fSa2J; Tue, 26 Jun 2018 08:18:53 -0600 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: Automatically populate resolv.conf when new DNS is acquired To: cygwin@cygwin.com References: <65242f5d-cc15-0024-47a8-0ce6be81aced@mail.com> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: Date: Tue, 26 Jun 2018 19:23:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <65242f5d-cc15-0024-47a8-0ce6be81aced@mail.com> Content-Type: multipart/mixed; boundary="------------4CFF37E51738BA13FADC21C4" X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00288.txt.bz2 --------------4CFF37E51738BA13FADC21C4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 1372 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. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada --------------4CFF37E51738BA13FADC21C4 Content-Type: text/plain; charset=UTF-8; name="resolv.awk" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="resolv.awk" Content-length: 1042 IyEvdXNyL2Jpbi9hd2sgLWYKIyByZXNvbHYuYXdrIC0gY3JlYXRlIFdpbmRv d3MgcmVzb2x2LmNvbmYgZnJvbSBpcGNvbmZpZyAvYWxsIG91dHB1dAoKCQkJ CXsgc3ViKCAvXHIvLCAiIiwgJE5GKSB9CSMgdHJpbSBccgoKIyBjb2xsZWN0 IEROUyBkb21haW4gc3VmZml4ZXMKL0RbTm5dW1NzXVxzU3VmZml4W146XSo6 XHNcUy8JeyBkb21haW5bJE5GXSA9ICRORiB9CgojIGNvbGxlY3QgRE5TIHNl YXJjaCBzdWZmaXhlcwovU2VhcmNoXHNMaXN0W146XSo6XHNcUy8JeyBzZWFy Y2hbJE5GXSA9ICRORiB9CgojIGNvbGxlY3QgRE5TIHNlcnZlciBJUCBhZGRy ZXNzZXMKL0ROU1xzU2VydmVyc1teOl0qOlxzXFMvCXsgZG5zID0gMSB9CQkJ IyBlbmFibGUKCmRucyAmJiAkTkYgfiAvXlswLTkuXSskLwl7IG5hbWVzZXJ2 ZXJbKytuc10gPSAkTkYgfQkjIGNvbGxlY3QKCmRucyAmJiAkTkYgIX4gL15b MC05Ll0rJC8JeyBkbnMgPSAwIH0JCQkjIGRpc2FibGUKCiMgb3V0cHV0IHVu aXF1ZSByZXNvbHYuY29uZiBlbnRyaWVzCkVORCB7CiAgICBmb3IgKG4gPSAx OyBuIDw9IG5zOyArK24pCXsgcHJpbnQgIm5hbWVzZXJ2ZXIiLCBuYW1lc2Vy dmVyW25dIH0KCiAgICBmb3IgKGQgaW4gZG9tYWluKQkJeyBwcmludCAiZG9t YWluIiwgZG9tYWluW2RdIH0KCiAgICBwID0gInNlYXJjaCIKCiAgICBmb3Ig KHMgaW4gc2VhcmNoKQkJewoJcHJpbnRmICIlcyAlcyIsIHAsIHNlYXJjaFtz XQoJcCA9ICIiCiAgICB9CgogICAgaWYgKCFwKQkJCXsgcHJpbnQgcCB9Cn0K Cg== --------------4CFF37E51738BA13FADC21C4 Content-Type: text/plain; charset=us-ascii Content-length: 219 -- 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 --------------4CFF37E51738BA13FADC21C4--