Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostname --fqdn broken when enableIPv6 = false #196934

Closed
thomask77 opened this issue Oct 20, 2022 · 6 comments · Fixed by #263634
Closed

hostname --fqdn broken when enableIPv6 = false #196934

thomask77 opened this issue Oct 20, 2022 · 6 comments · Fixed by #263634

Comments

@thomask77
Copy link

Describe the bug

In NixOS 22.05, the domain name is not set correctly when networking.enableIPv6 is set to false.

Steps To Reproduce

  1. It's working with IPv6:
{
  networking.hostName = "foo";
  networking.domain = "bar.baz";
  networking.enableIPv6 = true;
}
$ hostname --fqdn
foo.bar.baz
  1. .. but broken without:
{
  networking.hostName = "foo";
  networking.domain = "bar.baz";
  networking.enableIPv6 = false;
}
$ hostname --fqdn
foo

Expected behavior

Obviously, it should work in both cases.

Additional context

The issue seems to be related to nscd:
systemctl stop nscd also fixes the problem.

Similar issues seem to have been discussed in #1248, #10183 and #87633, but it's still broken.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.74, NixOS, 22.05 (Quokka), 22.05.3702.c5203abb132`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `"nixos-22.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@soupglasses
Copy link
Member

soupglasses commented Oct 26, 2022

I also seem to have hit this, but do not run networking.enableIPv6 = false, but a customized networking.extraHosts. I have however not tested removing extraHosts, as my servers rely on the configuration section to run.

Have a feeling it may be a fragile section when changes in networking. happens. Also stopping nscd solves it as well. Running nixos unstable.

@e1mo
Copy link
Member

e1mo commented Mar 3, 2023

I can reproduce this on nixos-unstable (without disabling IPv6), but also managed to get it working when stopping nscd.
I found https://superuser.com/a/161217 while googling around. And while this Archlinux BBS article points out a possible solution1, I did not find this to be working for me.

Footnotes

  1. Effectively translating to system.nssDatabases.hosts = lib.mkOrder 200 ["files"];

@s1341
Copy link
Contributor

s1341 commented Mar 7, 2023

I've also encountered this issue, with the same reproduction and issues as @e1mo.

Any idea how to resolve this? I particularly need to be able to set domain for containers using containers.<name>...

@s1341
Copy link
Contributor

s1341 commented Mar 7, 2023

FWIW, setting services.nscd.enableNsncd to false seems to resolve this issue.

cc @flokli

@flokli
Copy link
Contributor

flokli commented Mar 7, 2023

Hmm, this doesn't make too much sense - I'd assume nsncd and nscd should behave the same when it comes to that. They're simply calling out to the same NSS modules to do the work.

We do have nixos/tests/hostname.nix which tests that hostname --fqdn works. It currently seems to be failing in the hostname --fqdn testcase, when run with nsncd, and succeeds when setting services.nscd.enableNsncd to false. - cc @NinjaTrappeur

Let's figure out this regression first, and not draw too early conclusions about this being a "IPv6 is disabled issue".

@picnoir
Copy link
Member

picnoir commented Mar 7, 2023

So, there's definitely something wrong with the current nsncd implementation.

Dumping the Nscd socket, we can see that nsncd is lacking some getai entries. Entries that are probably used by hostname to get the FQDN:

NSNCD:

mars 07 14:24:18 framework sockdump[96606]: 14:24:18.768 >>> process hostname [98811 -> 70129] len 18(18)
mars 07 14:24:18 framework sockdump[96606]: 0000  02 00 00 00 0d 00 00 00  06 00 00 00 68 6f 73 74  ............host
mars 07 14:24:18 framework sockdump[96606]: 0010  73 00                                             s.
mars 07 14:24:18 framework sockdump[96606]: 14:24:18.768 >>> process hostname [98811 -> 70129] len 22(22)
mars 07 14:24:18 framework sockdump[96606]: 0000  02 00 00 00 05 00 00 00  0a 00 00 00 66 72 61 6d  ............fram
mars 07 14:24:18 framework sockdump[96606]: 0010  65 77 6f 72 6b 00                                 ework.


NSCD:

mars 07 14:25:53 framework sockdump[96606]: 14:25:53.784 >>> process hostname [101011 -> 100886] len 22(22)
mars 07 14:25:53 framework sockdump[96606]: 0000  02 00 00 00 05 00 00 00  0a 00 00 00 66 72 61 6d  ............fram
mars 07 14:25:53 framework sockdump[96606]: 0010  65 77 6f 72 6b 00                                 ework.
mars 07 14:25:53 framework sockdump[96606]: 14:25:53.784 >>> process nscd [100886 -> 101011] len 90(90)
mars 07 14:25:53 framework sockdump[96606]: 0000  02 00 00 00 01 00 00 00  1c 00 00 00 01 00 00 00  ................
mars 07 14:25:53 framework sockdump[96606]: 0010  0a 00 00 00 10 00 00 00  01 00 00 00 00 00 00 00  ................
mars 07 14:25:53 framework sockdump[96606]: 0020  66 72 61 6d 65 77 6f 72  6b 2e 61 6c 74 65 72 6e  framework.altern
mars 07 14:25:53 framework sockdump[96606]: 0030  61 74 69 76 65 62 69 74  2e 66 72 00 0a 00 00 00  ativebit.fr.....
mars 07 14:25:53 framework sockdump[96606]: 0040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 01  ................
mars 07 14:25:53 framework sockdump[96606]: 0050  66 72 61 6d 65 77 6f 72  6b 00                    framework.

Let's track and fix this issue on the Nsncd repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants