You are not logged in.
Hi there,
So, I have a host name configured in /etc/hosts that points to a a Linode IP, let's call these somehost.com and IP1. Then there is the same somehost.com name configured in a GoDaddy DNS pointing to another Linode IP, let's call it IP2. The reason for the /etc/hosts IP1 is to test a new version of the site that's live on IP2.
My problem is that sometimes somehost.com resolves to IP1, some other times it resolves to IP2, with no apparent rule. This is happening for ping&host commands and browser as well.
My /etc/nsswitch.conf has the following content:
# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.
passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd
publickey: files
hosts: files mymachines resolve [!UNAVAIL=return] myhostname dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
netgroup: filesNotice the "hosts:" entry having "files" as the first item.
It's driving me mad. Any ideas? Thanks in advance.
Last edited by mdcclxv (2022-09-19 13:17:06)
Offline
Not an explanation for the situation you described, but not all software respects /etc/nsswitch.conf. Some programs read /etc/resolv.conf directly.
Offline
Not an explanation for the situation you described, but not all software respects /etc/nsswitch.conf. Some programs read /etc/resolv.conf directly.
I've been reading about that, but then at least ping&host should be consistent. They are not.
Offline
This is a capture of the host output, with certain text removed for anonymity.
/zork: host www.___________care.com
www.___________care.com is an alias for ___________care.com.
___________care.com has address __.__.223.158
/zork: host www.___________care.com
www.___________care.com is an alias for ___________care.com.
___________care.com has address ___.___.0.85The first output is IP2, the second output is IP1 (from my original post).
Offline
Do you use systemd-resolved or any other caching daemon?
Can you reliably redirect hte domain to 127.0.0.1 or 0.0.0.0
On
strace ping idnet.ua-corp.com 2>&1 | grep -E '(hosts|nss)'does /etc/hosts get read even when it's ignored?
Offline
Do you use systemd-resolved or any other caching daemon?
No, plain arch installation.
Can you reliably redirect hte domain to 127.0.0.1 or 0.0.0.0
Yes, 127.0.0.1 works 100%.
On
strace ping idnet.ua-corp.com 2>&1 | grep -E '(hosts|nss)'does /etc/hosts get read even when it's ignored?
Looks like it does:
/zork: strace ping idnet.ua-corp.com 2>&1 | grep -E '(hosts|nss)'
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=359, ...}, 0) = 0
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/lib/libnss_mymachines.so.2", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/lib/libnss_resolve.so.2", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/lib/libnss_myhostname.so.2", O_RDONLY|O_CLOEXEC) = 4Offline
Found the issue, please don't laugh.
1. There was a typo in /etc/hosts, a comma instead of a dot before the com part. So the entry from /etc/hosts was being ignored all the time as it was invalid.
2. The reason for mixed resolving, which now it's not happening anymore, is that a colleague of mine performed a DNS migration from one GoDaddy account to another, without informing me, so for a while both DNS entries were valid, the old one from caches, the new one from the migrated DNS. This only hit me after I spotted the comma mistake (after reverting from the above 127.0.0.1 test) and questioned the said colleague about DNS migration status.
But as there is a little good in all evil, this post was useful for I learned about this neat strace utility, thank you Seth.
And thank you all for your time.
Offline
Edit: moot.
Last edited by seth (2022-09-19 13:17:28)
Offline