Sven Luijten

Use different nameservers for a single subdomain

Published on 1 minute to read

For this website, I wanted a way to create so-called "review apps" so I can preview pull requests on preview-<PR>.website.sven.luijten.dev. This turns out to be a built-in feature with Vercel, but their documentation instructed me to point luijten.dev's nameservers to theirs.

I wanted to find a way around this so that I could keep the nameservers for all my domains in Cloudflare. After a quick Google search, I came across the NS record you can add to your domain. This allows you to "delegate" the nameservers for a given (sub)domain down to another authoritative nameserver, like Vercel's.

Since I manage my DNS with DNSControl, I added an NS record for website.sven pointing to Vercel's nameserver:

D('luijten.dev', REG_NONE, DnsProvider(DNS_CLOUDFLARE),
    // ...

    NS('website.sven', 'ns1.vercel-dns.com.'),
    NS('website.sven', 'ns2.vercel-dns.com.')
);

This tells all traffic to website.sven.luijten.dev and any subdomain (so <anything>.website.sven.luijten.dev) to use Vercel's nameservers.