mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-25 12:09:15 -05:00
services: dnsmasq: Support the --address flag.
Introduce a new `addresses' field that translates to passing `--address=' multiple times to dnsmasq. * gnu/services/dns.scm (<dnsmasq-configuration>): Add an addresses field. (dnsmasq-shepherd-service): Match the addresses field and translate it to multiple '--address=' flags. * doc/guix.texi (DNS Services): Document it. Signed-off-by: 宋文武 <iyzsong@member.fsf.org>
This commit is contained in:
parent
f2531a254f
commit
5a0b78e62b
2 changed files with 26 additions and 1 deletions
|
@ -78,6 +78,7 @@ Copyright @copyright{} 2020 Jack Hill@*
|
||||||
Copyright @copyright{} 2020 Naga Malleswari@*
|
Copyright @copyright{} 2020 Naga Malleswari@*
|
||||||
Copyright @copyright{} 2020 Brice Waegeneire@*
|
Copyright @copyright{} 2020 Brice Waegeneire@*
|
||||||
Copyright @copyright{} 2020 R Veera Kumar@*
|
Copyright @copyright{} 2020 R Veera Kumar@*
|
||||||
|
Copyright @copyright{} 2020 Pierre Langlois@*
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
@ -21874,6 +21875,25 @@ When true, don't read @var{resolv-file}.
|
||||||
@item @code{servers} (default: @code{'()})
|
@item @code{servers} (default: @code{'()})
|
||||||
Specify IP address of upstream servers directly.
|
Specify IP address of upstream servers directly.
|
||||||
|
|
||||||
|
@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})
|
@item @code{cache-size} (default: @code{150})
|
||||||
Set the size of dnsmasq's cache. Setting the cache size to zero
|
Set the size of dnsmasq's cache. Setting the cache size to zero
|
||||||
disables caching.
|
disables caching.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
|
;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
|
||||||
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
|
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
|
||||||
|
;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -748,6 +749,8 @@ (define-record-type* <dnsmasq-configuration>
|
||||||
(default #f)) ;boolean
|
(default #f)) ;boolean
|
||||||
(servers dnsmasq-configuration-servers
|
(servers dnsmasq-configuration-servers
|
||||||
(default '())) ;list of string
|
(default '())) ;list of string
|
||||||
|
(addresses dnsmasq-configuration-addresses
|
||||||
|
(default '())) ;list of string
|
||||||
(cache-size dnsmasq-configuration-cache-size
|
(cache-size dnsmasq-configuration-cache-size
|
||||||
(default 150)) ;integer
|
(default 150)) ;integer
|
||||||
(negative-cache? dnsmasq-configuration-negative-cache?
|
(negative-cache? dnsmasq-configuration-negative-cache?
|
||||||
|
@ -759,7 +762,7 @@ (define dnsmasq-shepherd-service
|
||||||
no-hosts?
|
no-hosts?
|
||||||
port local-service? listen-addresses
|
port local-service? listen-addresses
|
||||||
resolv-file no-resolv? servers
|
resolv-file no-resolv? servers
|
||||||
cache-size negative-cache?)
|
addresses cache-size negative-cache?)
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
(provision '(dnsmasq))
|
(provision '(dnsmasq))
|
||||||
(requirement '(networking))
|
(requirement '(networking))
|
||||||
|
@ -783,6 +786,8 @@ (define dnsmasq-shepherd-service
|
||||||
'())
|
'())
|
||||||
#$@(map (cut format #f "--server=~a" <>)
|
#$@(map (cut format #f "--server=~a" <>)
|
||||||
servers)
|
servers)
|
||||||
|
#$@(map (cut format #f "--address=~a" <>)
|
||||||
|
addresses)
|
||||||
#$(format #f "--cache-size=~a" cache-size)
|
#$(format #f "--cache-size=~a" cache-size)
|
||||||
#$@(if negative-cache?
|
#$@(if negative-cache?
|
||||||
'()
|
'()
|
||||||
|
|
Loading…
Reference in a new issue