Despite modifying my hosts file, the DNS address for hosts is still displayed when using the host command. For instance:
$ grep -E "hosts|ipnodes" /etc/nsswitch.conf
hosts: files dns mymachines myhostname
$ grep google.com /etc/hosts
2401:db00:25ff:c83:: google.com
$ host google.com
google.com has address 142.250.217.78
google.com has IPv6 address 2607:f8b0:400a:80a::200e
google.com mail is handled by 10 smtp.google.com.
The BIND 9.3 command host does not follow the /etc/nsswitch.conf policy.
$ host -V
host 9.11.36-RedHat-9.11.36-8.el8
$ cat /etc/redhat-release
CentOS Stream release 8
nslookup, dig, and host are tools for querying DNS name servers. They don't follow nsswitch.
$ dig AAAA google.com +short
2607:f8b0:400a:80a::200e
$ nslookup google.com
Server: 2401:db00:eef0:a52::
Address: 2401:db00:eef0:a52::#53
Non-authoritative answer:
Name: google.com
Address: 142.250.217.110
Name: google.com
Address: 2607:f8b0:400a:80a::200e
$ ping google.com
PING google.com(google.com (2401:db00:25ff:c83::)) 56 data bytes
^C
--- google.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1061ms
$ getent hosts google.com
2401:db00:25ff:c83:: google.com
>>> import socket
>>> socket.getaddrinfo('google.com', None, socket.AF_INET6)
[(<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('2401:db00:25ff:c83::', 0, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('2401:db00:25ff:c83::', 0, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_RAW: 3>, 0, '', ('2401:db00:25ff:c83::', 0, 0, 0))]
resolveip follows nsswitch, but only works for IPv4.
$ resolveip google.com
IP address of google.com is 1.2.3.4