From nobody Sat Aug 05 18:19:45 2023 X-Original-To: freebsd-questions@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 4RJ9q64ZBcz4mN5B for ; Sat, 5 Aug 2023 18:20:02 +0000 (UTC) (envelope-from 0x1eef@protonmail.com) Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "protonmail.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RJ9q569R9z4VtZ for ; Sat, 5 Aug 2023 18:20:01 +0000 (UTC) (envelope-from 0x1eef@protonmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=protonmail.com header.s=protonmail3 header.b=uQ7kwpf6; spf=pass (mx1.freebsd.org: domain of 0x1eef@protonmail.com designates 185.70.40.131 as permitted sender) smtp.mailfrom=0x1eef@protonmail.com; dmarc=pass (policy=quarantine) header.from=protonmail.com Date: Sat, 05 Aug 2023 18:19:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1691259597; x=1691518797; bh=/8JAwDhQbyIBvwv34mUub78hUZo3lbQoxkRRte7jbKg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=uQ7kwpf6Y/pnpHl2Pzb2lfzKSuf2z4LOyXGp0PPuqqMlO9vSjSb5pvwjqdZDcrf9P OWWsNKfB+vcknb1I7aowIuhAI/Jp0Yl3NL9kdOvORpPhkS0hnQjWCeO8MbEsMw6kH+ 7AZwrBh3nBvx/PMVO0vLrg/naPPuzLvZhbjcbhWtmvhmqu7gfettf1zfeBLS1ldf2N mq4jTTZiFQsDUaQ7m/PW2V3iPMxatITf3haNEWYQQrBZINFrUgVtOMYuVCPDeJo4KM 9MJJl8t/jOC/aGpY8ZaoqghIma6EyWjsbf7NaaPRDyV0GEL32YtV6Q9xLyWojpnJsU nRFi1zlcnuvEA== To: Steven Friedrich From: 0x1eef <0x1eef@protonmail.com> Cc: freebsd@vanderzwan.org, FreeBSD Questions Mailing List Subject: Re: Using /etc/hosts, not dns Message-ID: In-Reply-To: <6c840288-0446-122d-7d97-d6b02982e27c@Gmail.com> References: <846f37ec-c0b3-0b1a-6294-1da6a9260777@Gmail.com> <1ED24C4A-FABF-4096-970D-4017616FC124@vanderzwan.org> <6c840288-0446-122d-7d97-d6b02982e27c@Gmail.com> Feedback-ID: 39071764:user:proton List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.27 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.87)[-0.869]; DMARC_POLICY_ALLOW(-0.50)[protonmail.com,quarantine]; RWL_MAILSPIKE_EXCELLENT(-0.40)[185.70.40.131:from]; R_SPF_ALLOW(-0.20)[+ip4:185.70.40.0/24]; R_DKIM_ALLOW(-0.20)[protonmail.com:s=protonmail3]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[gmail.com]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[protonmail.com]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ASN(0.00)[asn:62371, ipnet:185.70.40.0/24, country:CH]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[protonmail.com:+]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[protonmail.com]; MID_RHS_MATCH_FROM(0.00)[] X-Spamd-Bar: --- X-Rspamd-Queue-Id: 4RJ9q569R9z4VtZ > Correct, Linux still works. After all these years and my extensive Unix > experience, I am abandoning FreeBSD. You have completely abandoned > common sense. I thought this might be an interesting bit of information to add to the thread.=20 On OpenBSD, /etc/resolv.conf supports a 'lookup' keyword that FreeBSD has not implemented (AFAICT).=20 From the man page: lookup This keyword is used by the library routines gethostbyname= (3) and gethostbyaddr(3). It specifies which databases should= be searched, and the order to do so. The legal space-separat= ed values are: bind Query a domain name server. file Search for entries in /etc/hosts. If the lookup keyword is not used in the system's resolv.c= onf file then the assumed order is bind file. Furthermore, if the system's resolv.conf file does not exist, then the onl= y database used is file. But the 'host' command is the same as FreeBSD, and does not consult /etc/ho= sts. It should still be possible to write a small C program that uses gethostbyn= ame(3), and that should respect the lookup order. As long as resolv.conf has=20 'lookup file bind' it would consult /etc/hosts first and then consult=20 name servers second. I wrote a proof of concept (I'm trying to learn C, so this was a good task= =20 for me): #include #include #include #define IPv4_FORMAT "%hhu.%hhu.%hhu.%hhu" int main(void) { struct hostent *ent; ent =3D gethostbyname2("read.amazon.com", AF_INET); if (h_errno =3D=3D NETDB_SUCCESS) { char *addr =3D ent->h_addr_list[0]; fprintf(stdout, IPv4_FORMAT, addr[0], addr[1], addr[2], addr[3]); fprintf(stdout, "\n"); } else { fprintf(stderr, "error: %s", hstrerror(h_errno)); } return 0; } 0x1eef