GoAdmio

nameservers

Set the nameservers (up to four) used in the DNS zones of all hosted domains, rebuild every zone, or print the current list with return

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/nameservers tells GoAdmio which nameservers this server uses when it hosts DNS for your domains with BIND. It:

With return, it only prints the saved list.

[!NOTE] This command changes what this server publishes as the nameservers. It does not change anything at your domain registrar. For each domain, the same nameservers must be set at the registrar, and the nameserver hostnames need glue records or A records that point to this server.

[!NOTE] The file /etc/nameservers also acts as a switch. named with restart refuses to run without it, and create only creates a zone for a new account when it exists.


Quick start

# Use ns1 and ns2 of your own domain
/go/nameservers ns1.example.com ns2.example.com

Syntax

/go/nameservers <ns1> [ns2] [ns3] [ns4]    # set the nameservers
/go/nameservers return                     # print the saved nameservers

Run the command as root.


Arguments

Position Name Required Notes
1 <ns1> Yes The first nameserver hostname, such as ns1.example.com. Its domain, example.com here, gets its own zone.
2 [ns2] No The second nameserver. Most registrars require at least two.
3 [ns3] No
4 [ns4] No
1 return — Instead of setting anything, print the saved list.

Running the command with no arguments exits silently with status 1. The hostnames are not checked.


Output

Setting nameservers

Nameservers changed to:
ns1.example.com
ns2.example.com


All four lines are printed, so unused nameservers appear as empty lines. The output of zone follows.

The return option

The saved nameservers are printed on one line, separated by |:

ns1.example.com|ns2.example.com||

Unused nameservers leave empty fields, so a list of two ends with ||. If /etc/nameservers does not exist, nothing useful is printed.

Exit codes

Situation Exit code
No arguments 1, no message
return Always 1
Setting nameservers The status of the last step

Every call is also appended to /var/log/go/nameservers.log.


Examples

# Two nameservers
/go/nameservers ns1.example.com ns2.example.com
# Four nameservers
/go/nameservers ns1.example.com ns2.example.com ns3.example.com ns4.example.com
# Show the saved nameservers
/go/nameservers return
# Check what the server answers for a domain
dig NS example.com @127.0.0.1 +short

Troubleshooting

Symptom Likely cause Fix
Nothing happens, exit code 1 No arguments were given. Pass at least one nameserver, or return.
return prints nothing or an error The nameservers were never set. Set them first.
return output ends with ` ` characters Unused nameservers are saved as empty lines.
Domains still use the old nameservers on the internet The registrar still has the old nameservers, or DNS has not propagated yet. Change them at the registrar, then wait.
A zone was created for an unexpected domain The domain of the first nameserver gets its own zone. Use a first nameserver whose domain you host here.
The nameserver hostnames do not resolve The domain that holds them has no A records for them, or there are no glue records at the registrar. Add A records for ns1 and ns2 pointing to this server's IP, and create the glue records at the registrar.
Errors from zone, or BIND is not running BIND is not installed or is stopped. Install it with named, then run again.
Please Setup a Nameserver. from named /etc/nameservers does not exist. Run this command.

Details

What is saved

/etc/nameservers always gets four lines, one per argument, and unused ones are blank. Running the command again replaces the whole file, so pass every nameserver you want to keep. The command does not remove the file. To stop using the server as a nameserver, delete /etc/nameservers by hand.

The main zone

The first nameserver is split at its first dot, and the rest is taken as a domain. For ns1.example.com that is example.com, and the command runs zone example.com main to create that zone. If the first nameserver has no dot, the whole name is used. If its domain is hosted elsewhere, a zone for it is still created on this server.

Using Cloudflare instead

If your domains' DNS is on Cloudflare, this server's BIND is not used for them, and you do not need this command. See dns.

What it does

flowchart TD
    A["nameservers ..."] --> B{"First argument is return?"}
    B -- "Yes" --> C["Print saved list, exit 1"]
    B -- "No" --> D{"Any arguments?"}
    D -- "No" --> X["Exit 1"]
    D -- "Yes" --> E["Write /etc/nameservers"]
    E --> F["Print the nameservers"]
    F --> G["Update every zone"]
    G --> H["Create the main zone of the first nameserver's domain"]
  1. Appends the command line to /var/log/go/nameservers.log.
  2. With return: reads /etc/nameservers, joins its lines with |, prints them, and exits with status 1.
  3. Exits with status 1 if there are no arguments.
  4. Writes the four arguments to /etc/nameservers, one per line, replacing the old file.
  5. Prints Nameservers changed to: and the four values.
  6. Runs /go/zone all update to update the zones of every hosted domain.
  7. Takes the first nameserver without its first label and runs /go/zone <domain> main.

See also

Command Description
named Restart BIND, or reinstall it and rebuild every zone
zone Create, update, or delete a DNS zone file and register it with BIND
dns Add one or all hosted domains to Cloudflare and set up their DNS zone
create Create a GoAdmio account from the command line
reversedns Check reverse DNS (rDNS) in GoAdmio
dynadot Set up a domain's DNS at Dynadot using the Dynadot API