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

Managing only partial domain records #19

Open
ndarilek opened this issue Dec 12, 2024 · 1 comment
Open

Managing only partial domain records #19

ndarilek opened this issue Dec 12, 2024 · 1 comment

Comments

@ndarilek
Copy link

This looks like a neat project. I'm struggling to figure out if it meets my use case.

My domain, example.com, has its DNS hosted with Cloudflare and I've created all the records with Pulumi. Unfortunately my Pulumi state got hosed so I'm looking to try migrating to this project.

I brought up a Nix server, hostname hub. I'd like to assign hub.example.com to its IP address declaratively. I have a flake-based config with each host in its own file. My initial goal is to try generating zone files to see if they look sensible/correct, then try working with cloudflare through octodns. I'm not sure which combination of baseDomains, subDomains and/or zones I need to pull this off. Here's what I have in flake.nix:

    let
...
      dnsConfig = {
        # inherit nixosConfigurations;
        extraConfig = import ./dns.nix;
      };
    in
...

      packages = forAllSystems (
        system:
        let
          generate = nixos-dns.utils.generate nixpkgs.legacyPackages.${system};
        in
        {
          # nix build .#zoneFiles
          zoneFiles = generate.zoneFiles dnsConfig;
        }
      );

Then I have this dns.nix:

{
  defaultTTL = 60;
  zones = {
    "example.com" =
      {
      };
  };
}

Then this individual host config:

  networking = {
    hostName = "hub";
    hostId = "91312b0a";
    usePredictableInterfaceNames = false;
    domains = {
      enable = true;
      baseDomains = {
        "hub.example.com" = {
          a.data = "MY IP HERE";
        };
      };
    };
  };

When I build zones to sanity-check the result before trying to add octodns, I get an empty file. I can configure the zones if I make the config exactly like the example, but I'd rather not keep it all in dns.nix--I'd rather keep the config for each server with the server.

Here's what I don't get:

  1. Is what I want possible with this project? (E.g. only configuring this specific subdomain and gradually migrating more domains over time.)
  2. If so, what's the minimum I'd need to assign an A record to hub.example.com in a specific host configuration?
  3. Can I generate a zone file with this config to sanity-check it first, or would that not work here? (E.g. maybe that only works if I'm configuring everything from the apex down?)

Thanks a bunch.

@ndarilek
Copy link
Author

Forgot to mention that I tried a few other variations of this, including putting subDomains directly in the host config. Everything I tried, except for just putting the records under zones in dns.nix, produced an empty zone file. So either I can't use that backend like this, or I'm configuring something wrong and don't know what combination I need.

Thanks again.

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

No branches or pull requests

1 participant