From nobody Sat Jul 02 08:49:33 2022 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DE8CE8A648D for ; Sat, 2 Jul 2022 08:49:51 +0000 (UTC) (envelope-from dave@dogwood.com) Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LZm3L5r4zz4SRm for ; Sat, 2 Jul 2022 08:49:50 +0000 (UTC) (envelope-from dave@dogwood.com) Received: by mail-pj1-x1031.google.com with SMTP id g16-20020a17090a7d1000b001ea9f820449so8619258pjl.5 for ; Sat, 02 Jul 2022 01:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dogwood.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=NZVUPANCgI3Zm+3cKP3JB8555gOJmhQnla+6MFmI81k=; b=Id0nFn8gS/15orcyCCBxeDGr1pOC5WafeLY0No8HYnI+Rf0WrV2ALPiEzVjmebdALr xN+RI28gmMKL+RQPukP63AzvHyGCGyHO4vqKj+l8L5xeqcdX5gq6fO7YF9lUwUbPg7o8 Y2gjG1w/pojfk8sa2A8HhZcpZlvWOJ2itsO3k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NZVUPANCgI3Zm+3cKP3JB8555gOJmhQnla+6MFmI81k=; b=f4UQpkhQfxZUvbizls+Abt41kYoAgFiLgPKJENMc45LDbLzCaJrDNhhrkad0ZW1hCr CwP2Im5KOhK6GExrCAyhs5MjXNiK4c9VzRWERVLiAUwD5J7EzzhACM3EuLwzRTHqKEcs oNs3kb05rUk+0AJWbbnmf1wp2BvBr//wQEeh7PQZCFWqpybBGxAR7fMnOVw7RHaz4Vmb nz5hQ/goGF60yd/tByiAIjOK5fR8WdkbV71c1qme6amwFDqqcFFvEHOXZXjP/q3dGwfP eO6mweoVHL+eqotuc4tvUcLkUuTv+PtK292ah2CCDg2PB3kOm+no8YcoJKcjAal2NvK4 iS1A== X-Gm-Message-State: AJIora/BX3Ypiy+eutmxBslHkbUPmWdmv2+RxccJ5h3c22zONi6mZ7hb xxoKs7rpxQDyELMixhuFhK0glZHzNOQWWv72F6pvV4ntzo4= X-Google-Smtp-Source: AGRyM1u7Z5T4uY57yhhJa52kqoJuvJRiFixsuEK8yxkxjRcslr3OiO0KVBJK0l/3IwO2OCRWYG/ncuAyvO9BTzcuSvU= X-Received: by 2002:a17:902:7e86:b0:16b:bcde:7cf3 with SMTP id z6-20020a1709027e8600b0016bbcde7cf3mr7756456pla.88.1656751784002; Sat, 02 Jul 2022 01:49:44 -0700 (PDT) List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: David Cornejo Date: Fri, 1 Jul 2022 22:49:33 -1000 Message-ID: Subject: Re: RPI4 + ntpdate + unbound To: John Kennedy Cc: freebsd-arm@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4LZm3L5r4zz4SRm X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dogwood.com header.s=google header.b=Id0nFn8g; dmarc=none; spf=pass (mx1.freebsd.org: domain of dave@dogwood.com designates 2607:f8b0:4864:20::1031 as permitted sender) smtp.mailfrom=dave@dogwood.com X-Spamd-Result: default: False [-3.29 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[dogwood.com:s=google]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; DMARC_NA(0.00)[dogwood.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[dogwood.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::1031:from]; NEURAL_HAM_SHORT(-0.79)[-0.788]; MLMMJ_DEST(0.00)[freebsd-arm]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Fri, Jul 1, 2022 at 6:03 PM John Kennedy wrote: > > So I've got a RPI4 (no system time stored in NVRAM) that I did a stock > type FreeBSD install on setting the time with ntpdate and the unbound > DNS server (aiming for DNSSEC). As many people have noted before me, > that setup is sort of broken because you can't look up DNSSEC hosts if > you think it's 1970. No NTP time servers =3D=3D no date reset =3D=3D no = DNS. > > This example is probably terrible, but starting talk point: > > $ grep -E '(ntpdate|unbound)' /etc/rc.conf > ntpdate_enable=3D"YES" > ntpdate_XXX_dns=3D"8.8.8.8" > ntpdate_hosts=3D"0.freebsd.pool.ntp.org" > local_unbound_enable=3D"YES" > > I basically added ntpdate_XXX_dns (pick a better name) to trigger the > new behavior. If it at the ntpdate_hosts are set (I needed something to > feed to the /usr/bin/host program), then I build a list of IPs to feed > to ntpdate bypassing unbound's DNSSEC lookup. > > The tee to /dev/console is just a way of showing what is processed: > > # /etc/rc.d/ntpdate restart > Using domain server: > Name: 8.8.8.8 > Address: 8.8.8.8#53 > Aliases: > > 0.freebsd.pool.ntp.org has address 51.89.85.70 > 0.freebsd.pool.ntp.org has address 23.92.64.226 > 0.freebsd.pool.ntp.org has address 178.62.16.103 > 0.freebsd.pool.ntp.org has address 130.255.77.87 > XXX ntpdate_hosts -> 51.89.85.70 23.92.64.226 178.62.16.103 130.2= 55.77.87 > Setting date via ntp. > 1 Jul 20:39:15 ntpdate[19554]: step time server 178.62.16.103 of= fset -0.006001 sec > > That is a totally insecure way of ingesting IPs (trusting DNS, which > might potentially find a way to append shell commands). But again, just > a starting point to throw ideas at. > > --- /usr/src/libexec/rc/rc.d/ntpdate 2022-06-25 15:39:37.070933000 -07= 00 > +++ /etc/rc.d/ntpdate 2022-07-01 20:39:01.793869000 -0700 > @@ -25,6 +25,12 @@ > else {print $2}} > ' < "$ntpdate_config"` > fi > + if [ -n " $ntpdate_XXX_dns" -a -n "$ntpdate_hosts" ]; then > + host $ntpdate_hosts $ntpdate_XXX_dns > + ntpdate_hosts=3D`host 0.freebsd.pool.ntp.org 8.8.8.8 | te= e /dev/console | \ > + grep 'has address' | sed -E 's/^.* has address (.= *$)/\1/' | xargs` > + echo "XXX ntpdate_hosts -> $ntpdate_hosts" > + fi > if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then > echo "Setting date via ntp." > ${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts > I always hated this about the RPIs - I put a DS3231 on mine and the problem disappears. (there are cheaper chips, less temperature compensation that should work fine). Your solution also requires a working internet connection. I've also added a junk-box stratum 1 server on a UPS, while this was not expensive, it is a lot more than an add-on clock, When completely isolated from the internet I can still sync my clocks. dave c --=20 Kailua, Hawai=CA=BBi