From patchwork Thu Jul 27 02:04:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 52223 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D6EF827BBE2; Thu, 27 Jul 2023 03:15:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8240127BBE9 for ; Thu, 27 Jul 2023 03:15:27 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOqQ8-00086L-L8; Wed, 26 Jul 2023 22:08:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOqQ7-00085y-B3 for guix-patches@gnu.org; Wed, 26 Jul 2023 22:08:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOqQ7-0003Cm-30 for guix-patches@gnu.org; Wed, 26 Jul 2023 22:08:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qOqQ6-0008QN-JB for guix-patches@gnu.org; Wed, 26 Jul 2023 22:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64883] [PATCH] doc: cookbook: Document a dynamic DNS update mcron job. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Jul 2023 02:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64883 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64883@debbugs.gnu.org, maxim.cournoyer@gmail.com X-Debbugs-Original-To: guix-patches@gnu.org, maxim.cournoyer@gmail.com Received: via spool by submit@debbugs.gnu.org id=B.169042365332342 (code B ref -1); Thu, 27 Jul 2023 02:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 Jul 2023 02:07:33 +0000 Received: from localhost ([127.0.0.1]:40423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOqPc-0008Pa-NI for submit@debbugs.gnu.org; Wed, 26 Jul 2023 22:07:33 -0400 Received: from lists.gnu.org ([2001:470:142::17]:58610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOqPZ-0008PL-75 for submit@debbugs.gnu.org; Wed, 26 Jul 2023 22:07:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOqPT-000849-M0 for guix-patches@gnu.org; Wed, 26 Jul 2023 22:07:23 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOqPR-0002WT-QI for guix-patches@gnu.org; Wed, 26 Jul 2023 22:07:23 -0400 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-4039a42467fso2704991cf.3 for ; Wed, 26 Jul 2023 19:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690423640; x=1691028440; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=aoHCc6oi4+bF64Itm71sY1QgaYeldWHb1Ke9NuHK9aw=; b=bgC8+Q/g6v+hwciWjbKNCNWP9gJNEj09H9QMMSyd4uqvbIWDjalTxP6d4nS+lezAc8 mEu+BZ3rM57aGr05rw/hUUAxpVP9NiOaIg1Z4nVEkhuG40q1wil7b3ltlJztBpqr0Gi1 MuiYCCOMxhZg64zXKKeUYzHLQZwSn/P4orx31PD1qhOZ+kqdyqdZ7fP2B3aDIy7mbRCY yuNfHfFd/iZwQq3OokL2fOxhcA7FhuSSkFrhMBMN8eTWHBc00gC25vH3QRNg5rXf1k71 BkUdLZFeoHP20uR+M7gAfEdKL9gxxgK5/TAKnEfGCFNqoVyQF3MrB9474usAkE9KcEkc 1OjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690423640; x=1691028440; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aoHCc6oi4+bF64Itm71sY1QgaYeldWHb1Ke9NuHK9aw=; b=cypm11+vWRm4NnL01SCrP2jIKd25JXcVexmb4rQSRd6RWFJyt4ZihYxUgNAs7Stywm DbPGOhoPle/6fZ6OaOW9bohRrBgfYG4IIQxrizGgP3oXInOTbmwHT3bceyV531USDMJe QwHKLihAATFH6N4uiSfThwq948q2TrZ1kjURjlmFDhjKiLvCTolpmV8rja7oraYz/C/v 1t8xipP5bY1zhoOOyMJzHtnScgvjNKmF77Ts+EdjfcD+p0qquzCkke6zbF+wHnhQLOXL siYYRb3ie2SWyLtwKWlwFmaZy4nLRkw40GIJOsWZRtlcpQYUFC3frIAsPEWVOb3iGVGU SYfA== X-Gm-Message-State: ABy/qLaiLvQAxAat/qlkIHv7Ecb5y+NK9D1hkVKRlxXkQt531rHelqRi JyYlr0lRW07hOF9AEybGxHoaX5daxY4uDQ== X-Google-Smtp-Source: APBJJlGS8dDY8/6r0yiP/DOu2z9U1+v2Q38hVff0ILmkH2gcZKstNb9V+Mn8i/mV+RUzSaurXiiLsA== X-Received: by 2002:ac8:7dcf:0:b0:404:a649:879c with SMTP id c15-20020ac87dcf000000b00404a649879cmr4246111qte.49.1690423640206; Wed, 26 Jul 2023 19:07:20 -0700 (PDT) Received: from localhost.localdomain (dsl-10-141-65.b2b2c.ca. [72.10.141.65]) by smtp.gmail.com with ESMTPSA id y25-20020ac87c99000000b00403b3156f18sm114805qtv.8.2023.07.26.19.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 19:07:19 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Jul 2023 22:04:40 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * doc/guix-cookbook.texi (System Configuration) : New subsection. --- doc/guix-cookbook.texi | 56 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) base-commit: c7e45139faa27b60f2c7d0a4bc140f9793d97d47 diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 2e58c6c795..8e069f921e 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -1460,9 +1460,10 @@ System Configuration * Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System. * Guix System Image API:: Customizing images to target specific platforms. * Using security keys:: How to use security keys with Guix System. +* Dynamic DNS mcron job:: Job to update the IP address behind a DuckDNS host name. * Connecting to Wireguard VPN:: Connecting to a Wireguard VPN. * Customizing a Window Manager:: Handle customization of a Window manager on Guix System. -* Running Guix on a Linode Server:: Running Guix on a Linode Server +* Running Guix on a Linode Server:: Running Guix on a Linode Server. * Setting up a bind mount:: Setting up a bind mount in the file-systems definition. * Getting substitutes from Tor:: Configuring Guix daemon to get substitutes through Tor. * Setting up NGINX with Lua:: Configuring NGINX web-server to load Lua modules. @@ -2022,6 +2023,59 @@ Using security keys ready to be used with applications supporting two-factor authentication (2FA). +@node Dynamic DNS mcron job +@section Dynamic DNS mcron job + +@cindex dynamic DNS, DDNS +If your @acronym{ISP, Internet Service Provider} only provides dynamic +IP addresses, it can be useful to setup a dynamic @acronym{DNS, Domain +Name System} (also known as @acronym{DDNS, Dynamic DNS}) service to +associate a static host name to a public but dynamic (often changing) IP +address. There are multiple existing services that can be used for +this; in the following mcron job, @url{https://duckdns.org, DuckDNS} is +used. It should also work with other dynamic DNS services that offer a +similar interface to update the IP address, such as +@url{https://freedns.afraid.org/}, with minor adjustments. + +The mcron job is provided below, where @var{DOMAIN} should be +substituted for your own domain prefix, and the DuckDNS provided token +associated to @var{DOMAIN} added to the +@file{/etc/duckdns/@var{DOMAIN}.token} file. + +@lisp +(define duckdns-job + ;; Update personal domain IP every 5 minutes. + #~(job '(next-minute (range 0 60 5)) + #$(program-file + "duckdns-update" + (with-extensions (list guile-gnutls) ;required by (web client) + #~(begin + (use-modules (ice-9 textual-ports) + (web client)) + (let ((token (string-trim-both + (call-with-input-file "/etc/duckdns/@var{DOMAIN}.token" + get-string-all))) + (query-template (string-append "https://www.duckdns.org/" + "update?domains=@var{DOMAIN}" + "&token=~a&ip="))) + (http-get (format #f query-template token)))))) + "duckdns-update" + #:user "nobody")) +@end lisp + +The job then needs to be added to the list of mcron jobs for your +system, using something like: + +@lisp +(operating-system + (services + (cons* (service mcron-service-type + (mcron-configuration + (jobs (list duckdns-job ...)))) + ... + %base-services))) +@end lisp + @node Connecting to Wireguard VPN @section Connecting to Wireguard VPN