From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:51861) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMxwh-00036i-LW for guix-patches@gnu.org; Fri, 10 Apr 2020 14:00:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMxwg-00075L-Em for guix-patches@gnu.org; Fri, 10 Apr 2020 14:00:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMxwg-00075B-Ax for guix-patches@gnu.org; Fri, 10 Apr 2020 14:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jMxwg-0007Dx-Aa for guix-patches@gnu.org; Fri, 10 Apr 2020 14:00:02 -0400 Subject: [bug#40545] [PATCH] services: dnsmasq: Support the --address flag. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:51636) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMxvt-00033P-JP for guix-patches@gnu.org; Fri, 10 Apr 2020 13:59:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMxvr-0006U4-E6 for guix-patches@gnu.org; Fri, 10 Apr 2020 13:59:13 -0400 Received: from mout.gmx.net ([212.227.15.18]:55927) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMxvq-0006Rv-My for guix-patches@gnu.org; Fri, 10 Apr 2020 13:59:11 -0400 Received: from vino ([92.95.5.39]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MIdeR-1jSgxS42Lt-00Ee0y for ; Fri, 10 Apr 2020 19:59:08 +0200 From: Pierre Langlois Date: Fri, 10 Apr 2020 18:59:06 +0100 Message-ID: <87wo6np6hh.fsf@gmx.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40545@debbugs.gnu.org --=-=-= Content-Type: text/plain Hello Guix! Here's a patch that allows passing the --address flag multiple times to dnsmasq. WDYT? Thanks, Pierre --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-services-dnsmasq-Support-the-address-flag.patch Content-Transfer-Encoding: quoted-printable >From 407265e5d9b0f863a8b14d74f6240ed102f9a907 Mon Sep 17 00:00:00 2001 From: Pierre Langlois Date: Fri, 10 Apr 2020 17:00:47 +0100 Subject: [PATCH] services: dnsmasq: Support the --address flag. Introduce a new `addresses' field that translates to passing `--address=3D' multiple times to dnsmasq. * gnu/services/dns.scm (): Add an addresses field. (dnsmasq-shepherd-service): Match the addresses field and translate it to multiple '--address=3D' flags. * doc/guix.texi (DNS Services): Document it. --- doc/guix.texi | 20 ++++++++++++++++++++ gnu/services/dns.scm | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 891e2693f6..7ca4bd6ef3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -77,6 +77,7 @@ Copyright @copyright{} 2020 Jakub K=C4=85dzio=C5=82ka@* Copyright @copyright{} 2020 Jack Hill@* Copyright @copyright{} 2020 Naga Malleswari@* Copyright @copyright{} 2020 Brice Waegeneire@* +Copyright @copyright{} 2020 Pierre Langlois@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -21772,6 +21773,25 @@ When true, don't read @var{resolv-file}. @item @code{servers} (default: @code{'()}) Specify IP address of upstream servers directly. =20 +@item @code{addresses} (default: @code{'()}) +For each entry, specify an IP address to return for any host in the +given domains. Queries in the domains are never forwarded and always +replied to with the specified IP address. + +This is useful for redirecting hosts locally, for example: + +@lisp +(service dnsmasq-service-type + (dnsmasq-configuration + (addresses + '(; Redirect to a local web-server. + "/example.org/127.0.0.1" + ; Redirect subdomain to a specific IP. + "/subdomain.example.org/192.168.1.42")))) +@end lisp + +Note that rules in @file{/etc/hosts} take precedence over this. + @item @code{cache-size} (default: @code{150}) Set the size of dnsmasq's cache. Setting the cache size to zero disables caching. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index a07946d085..478c837d13 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2017 Julien Lepiller ;;; Copyright =C2=A9 2018 Oleg Pykhalov +;;; Copyright =C2=A9 2020 Pierre Langlois ;;; ;;; This file is part of GNU Guix. ;;; @@ -748,6 +749,8 @@ cache.size =3D 100 * MB (default #f)) ;boolean (servers dnsmasq-configuration-servers (default '())) ;list of string + (addresses dnsmasq-configuration-addresses + (default '())) ;list of string (cache-size dnsmasq-configuration-cache-size (default 150)) ;integer (negative-cache? dnsmasq-configuration-negative-cache? @@ -759,7 +762,7 @@ cache.size =3D 100 * MB no-hosts? port local-service? listen-addresses resolv-file no-resolv? servers - cache-size negative-cache?) + addresses cache-size negative-cache?) (shepherd-service (provision '(dnsmasq)) (requirement '(networking)) @@ -783,6 +786,8 @@ cache.size =3D 100 * MB '()) #$@(map (cut format #f "--server=3D~a" <>) servers) + #$@(map (cut format #f "--address=3D~a" <>) + addresses) #$(format #f "--cache-size=3D~a" cache-size) #$@(if negative-cache? '() --=20 2.26.0 --=-=-=--