Set Up Custom Nameservers on Your VPS — A Fast, Step-by-Step Guide

Set Up Custom Nameservers on Your VPS — A Fast, Step-by-Step Guide

Want a more professional DNS footprint and full control over your domains? This fast, step-by-step guide will show you how to set up custom nameservers on your VPS, explain glue records and authoritative servers, and help you avoid common pitfalls.

Introduction

Custom nameservers let you present a professional domain infrastructure, increase brand trust, and gain granular control over DNS behaviour. For site owners, enterprises, and developers running services on a VPS, configuring your own nameservers (for example, ns1.example.com and ns2.example.com) is a common requirement. This article provides a fast, step-by-step technical guide to setting up custom nameservers on a VPS, explains how the pieces fit together, discusses common use cases and advantages, and offers practical recommendations when choosing a VPS provider.

How DNS and Custom Nameservers Work (Principles)

Before diving into configuration, it helps to understand the components involved and how they interact:

  • Registrar and Glue Records — Glue records are A (and sometimes AAAA) records stored at the registrar that map your custom nameserver hostnames (ns1/ns2) to IP addresses. They are required to break circular dependencies when a domain’s nameservers are subdomains of the same domain.
  • Authoritative DNS Server — This is the DNS server software running on your VPS (e.g., BIND9, PowerDNS, Knot, or a control panel-managed DNS). It holds the zone files for domains for which it is authoritative.
  • Resolver and Root/ TLD infrastructure — When a client queries a domain, resolvers consult the root servers and TLD servers, which provide the glue/NS delegations and then the authoritative server provides the actual records.
  • Reverse DNS (PTR) — Although not required for nameserver functionality, many services (mail, spam filtering) expect reverse DNS consistency; PTR records are set by the IP owner (your VPS provider).

Why Glue Records Matter

Suppose your domain example.com uses ns1.example.com and ns2.example.com as nameservers. If a resolver tries to locate the nameservers, it needs to know the IP addresses for ns1/ns2. But these are subdomains of example.com — so the resolver would need to query example.com to get them, which becomes circular. Glue records stored at the registrar resolve that loop by providing the IPs directly at the TLD level.

Typical Application Scenarios

Setting up custom nameservers is common in these scenarios:

  • Hosting providers and resellers who want to provide branded DNS to customers.
  • Companies that require centralized DNS under their own domain for brand consistency and internal policies.
  • Developers and sysadmins who require full control over DNS records, TTLs, and advanced features like DNSSEC or geo-aware responses.
  • High-availability deployments where you control multiple VPS instances across data centres to host redundant authoritative servers.

Step-by-Step Setup — Practical Implementation

The following steps assume you have at least one VPS with a public IP, domain registrar access, and basic shell skills. This guide uses BIND9 examples because BIND is widely available, but concepts apply to other DNS software.

Prerequisites

  • A registered domain (example.com) with registrar control panel access.
  • At least one VPS with a public IPv4 address (preferably two IPs or two VPSes for redundancy).
  • Root/administrative access to the VPS and ability to open firewall ports (UDP/TCP 53).
  • Ability to create glue records at your registrar (sometimes called “create host,” “register nameserver,” or “child nameserver”).

1. Install and configure BIND9 on the VPS

On Debian/Ubuntu:

  • sudo apt update && sudo apt install bind9 bind9utils

Create a primary zone file for example.com (usually under /etc/bind/zones/). Example minimal files:

  • zone file /etc/bind/zones/db.example.com containing SOA, NS, A records including entries for ns1 and ns2 pointing to your VPS IPs.

Example zone snippet (conceptual):

  • @ IN SOA ns1.example.com. hostmaster.example.com. (serial 2025112801; 3600; 1800; 604800; 86400)
  • @ IN NS ns1.example.com.
  • @ IN NS ns2.example.com.
  • ns1 IN A 203.0.113.10
  • ns2 IN A 203.0.113.11
  • @ IN A 203.0.113.20

Then add the zone to /etc/bind/named.conf.local:

  • zone “example.com” { type master; file “/etc/bind/zones/db.example.com”; };

Reload BIND and check logs for errors (journalctl -u bind9 or /var/log/syslog). Use named-checkzone and named-checkconf to validate configurations.

2. Open firewall and ensure UDP/TCP 53 reachable

Allow DNS traffic through the server firewall and any host-level firewall:

  • iptables/nftables: allow udp/tcp port 53.
  • cloud provider or VPS control panel: ensure no external port blocking for DNS.

Testing from another host:

  • dig @203.0.113.10 example.com A +short
  • dig @203.0.113.10 ns1.example.com A +short

3. Register glue records at the registrar

Log in to your domain registrar and look for sections labelled “Register nameserver,” “Create host,” or “Glue records.” Register ns1.example.com → 203.0.113.10 and ns2.example.com → 203.0.113.11. This step is crucial; without glue, many resolvers cannot reach your nameservers.

4. Delegate the domain to the custom nameservers

After glue registration, update the domain’s nameservers at the registrar to ns1.example.com and ns2.example.com. Note propagation can take time—usually within minutes to a few hours for the nameserver referral to propagate, although full caching lifetimes depend on TTLs and TLD policies.

5. Verify the delegation and authoritative responses

Use these commands to validate:

  • dig NS example.com +trace — traces from root to TLD to your authoritative servers.
  • dig @ns1.example.com example.com SOA — verifies your server is authoritative and returning proper SOA.
  • whois example.com — confirms registrar shows your custom nameservers.

Also confirm glue records exist in TLD nameservers by querying the parent nameserver for the TLD.

6. Configure redundancy and monitoring

Best practice is to have at least two authoritative nameservers on separate IPs and ideally in different networks. Options include:

  • Hosting ns1 and ns2 on two VPSes across different data centres (or using a secondary DNS provider for redundancy).
  • Configuring zone transfers (AXFR/IXFR) or using DNS NOTIFY so secondaries can replicate zones.
  • Monitoring DNS health with automated probes and alerting for response time and correctness.

Advanced Considerations and Best Practices

DNSSEC

If you want cryptographic authenticity of DNS data, enable DNSSEC. This requires generating zone signing keys (ZSK) and key signing keys (KSK), producing DS records, and adding the DS to the registrar. DNSSEC adds security but increases operational complexity—key rollover procedures must be established.

TTL and Caching Strategy

Tune TTLs based on how frequently records change. Short TTLs (e.g., 300 seconds) allow quick changes but increase query load; long TTLs reduce load but delay propagation. For nameserver A records and glue, longer TTLs are usually acceptable once stable.

Reverse DNS and Mail Considerations

For outgoing mail, ensure reverse PTRs for your mail server IPs are set and match forward records to avoid deliverability issues. PTR updates are typically performed through the VPS provider’s control panel—coordinate this with your provider.

Advantages of Running Your Own Nameservers vs. Third-Party DNS

  • Control: Full authority over record types, TTLs, transfers, and zone templates.
  • Branding: Use domain-based nameservers for a consistent corporate appearance.
  • Integration: Easier to implement custom logic (geo-DNS, API-driven provisioning, private records for internal use).
  • Cost & Flexibility: With VPS-hosted nameservers you control scaling and can integrate with infrastructure automation (Ansible, Terraform).

However, third-party managed DNS services often provide superior global Anycast networks, DDoS protection, and simplified management—factors to weigh depending on scale and threat model.

Choosing a VPS Provider for Authoritative DNS

When selecting a VPS to host authoritative nameservers, consider:

  • Network stability and uptime: DNS needs high availability and low latency. Look for providers with redundant backbones and SLA commitments.
  • Multiple IPs and locations: Ability to provision multiple IPs or multiple VPS instances in diverse regions supports redundancy.
  • Control panel capabilities: If you prefer managed stacks, check if the provider offers easy PTR configuration and firewall controls.
  • Security features: DDoS mitigation, private networking, and snapshot backups help operate authoritative services reliably.

For users seeking reliable, high-performance VPS options in the United States, consider providers that combine low-latency networks and cost-effective plans. For example, USA VPS solutions at VPS.DO provide suitable platforms to host authoritative DNS servers with flexible plans and control panel options for managing networking settings.

Summary

Configuring custom nameservers on a VPS involves three coordinated steps: running authoritative DNS software on your VPS, registering glue records at your registrar, and delegating the domain to those nameservers. Important operational considerations include firewall configuration, redundancy across IPs or locations, DNSSEC planning, and PTR/reverse DNS management for mail deliverability. Running your own nameservers delivers maximum control and branding benefits, but it requires careful attention to availability and security; for many use cases a hybrid approach (self-hosted primary and managed secondary, or vice versa) strikes a good balance.

If you need a performant and reliable VPS to host your authoritative DNS—whether for a single domain or a fleet of customer zones—explore USA VPS options at VPS.DO to find plans that match your redundancy and network requirements.

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!