Aesir NS ยท The management API

Freya NS API: the management side of the name server

Freya is where the people who run the name server are managed, where the zones and records it serves and the domains it blocks are managed, and where what it did can be looked up. It stores everything in MongoDB and checks each record with the validators of Njord, so everything stored is something the server can send.

  • Version 2.12.0
  • MIT licence
  • Swagger UI
  • Node.js 22

At a glance

Packagefreya-ns-api
Version2.12.0
LicenceMIT
Built onExpress 5 and MongoDB (Mongoose 9)
Used byOdin NS Manager

What it does

A REST API for everything the name server knows, described and ready to try at /api/docs.

  • Zones and records

    Create, change and delete zones and their A, AAAA, CNAME, MX, NS, PTR, SRV and TXT records. The SOA record and its serial are kept for you.

  • Standalone records

    Records that belong to no zone, for names that need no zone of their own, such as the machines of a home network.

  • Blocking

    Block lists downloaded from a URL, such as a hosts file, and domains blocked or allowed by hand.

  • Monitoring

    The queries the name server answered, its clients, and hourly metrics.

  • Sign-in

    Login with a token, logout and immediate revocation. Nothing but the login works without signing in.

  • Two-factor and API tokens

    An authenticator code after the password, and tokens for scripts with only the rights they need.

  • Audit trail

    Every change is written down before it is made: who, when, from where and what. A change that can not be recorded is refused.

  • Export and import

    Everything as one JSON document, to move it to another system.

  • HTTPS

    A certificate of Let’s Encrypt that renews itself, also for wildcard names through DNS validation, or one of your own.

  • Swagger UI

    The whole API, described and ready to try in the browser.

Try it

The API listens on http://localhost:45451 by default.

A name on the air in three requests

Sign in, create a zone, and add a record to it. The first answer holds the token, the second the id of the zone.

curl -X POST http://localhost:45451/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"<password>"}'

curl -X POST http://localhost:45451/api/zones \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"name":"example.com","soa":{"host":"ns1.example.com"}}'

curl -X POST http://localhost:45451/api/zones/<zoneId>/records \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"name":"www","type":"A","data":{"target":"192.0.2.1"}}' 

On the first start an admin account is made: with the password you set in FREYA_ADMIN_PWD, or a random one printed once. The same works in the browser at /api/docs.

What it needs

Node.js22 or newer
MongoDBA server the API can reach
Ports45451 for HTTP, 45452 for HTTPS (both can be changed)

The other modules

Each module has its own repository and version. A release of Odin pins the versions of the others, and the installer installs exactly those.

  • Odin NS Manager

    The service you install. It brings the others together: the DNS server, the management API, the interface and the installers.

  • Njord NS Server

    The DNS server engine in pure JavaScript: UDP and TCP, EDNS0, zone transfers and a recursor. It hands you each query as an object to answer.

  • Bragi NS Client

    A cached replacement of Node.js dns.lookup for outgoing connections, with round-robin and optional DNSSEC validation.