1 unstable release
0.2.3 | Sep 26, 2021 |
---|
#37 in #home
63KB
775 lines
dynnsd
A client and server for generating dynamic DNS entries.
- The ability to give your home router a DNS name.
dynnsd
is designed to help replace dyndns which was purchased by Oracle who subsequently sold domain registration to a third party.
Given the cheap price of virtual servers, and the good work of NLnetLabs its possible to run a pair of industrial strength DNS servers for about 5 bucks a month.
dynnsd
provides the dynamic DNS part of the service, i.e. providing home routers with Internet valid DNS addresses.
A server behind a NATted home router runs the client indicating its IP address and dynnsd server code writes out a zone file
including an A record and asks nsd
to re-read its config.
dynnsd-client
sends its IP to both nsd instances separately so there is no need for zone transfer. Its possible the instances get out of sync
but its also possible that neither have the correct IP.
Dynamic DNS Protocol
Protocol consists of 4 messages between client and server. Client runs on a home network, server runs on the same host as an nsd
server.
dynnsd-client
sends an ip_request message, it does not know its own IP address yet, dynnsd-client
may be behind a NAT router and have its source IP and port changed.
When the dynnsd
server receives an ip_request, it sends an ip_reply including the client's source IP address.
When the dynnsd-client
receives the ip_reply, it sends an ip_confirm request to one or more dynnsd
servers to indicate they should add the IP address
to DNS.
When a dynnsd
server receives an ip_confirm with an IP address that matches the source IP address, it creates a DNS A record.
; ddns
homesrv 5m IN A 23.24.25.26
and HUPs nsd
.
Zone Change Protocol
dynnsd
also supports a zone change message that changes the main zone file and HUPs nsd
.
For example, to fail over the zone to a backup data center or place the zone in maintenance mode. Dynamic hosts are copied to the new zone.
You can also send a ZONE_HUP to hup nsd
, for example after rsyncing static zone file changes.
Messages
Messages are 72 byte UDP messages containing fixed length fields.
IP_REQUEST
- 4 bytes - 23.1.0.0 - header, magic_number, msg type, 0, 0
- 4 bytes - 0.0.0.0
- 32 bytes - random
- 32 bytes - sha256 hash
IP_RESPONSE
- 4 bytes - 23.2.0.0
- 4 bytes - src ip address (human readable byte order)
- 32 bytes - random data
- 32 bytes - sha256 hash
IP_CONFIRM
- 4 bytes - 23.3.0.0
- 4 bytes - src ip address
- 1 byte - host_index, each dynnsd server supports up to 256 clients
- 23 bytes - random
- 8 bytes - minute of unix epoc (epoc / 60)
- 32 bytes - sha256 hash
IP_CREATED
- 4 bytes - 23.4.0.0
- 4 byte - host_index,0,0,0
- 32 bytes - random
- 32 bytes - sha256 hash
ZONE_CHANGE
- 4 bytes - 23.5.0.0 - header, magic_number, msg type, 0, 0
- 4 bytes - zone_index.0.0.0
- 32 bytes - random
- 32 bytes - sha256 hash
ZONE_CHANGED
- 4 bytes - 23.6.0.0 - header, magic_number, msg type, 0, 0
- 4 bytes - zone_index.0.0.0
- 32 bytes - random
- 32 bytes - sha256 hash
ZONE_HUP
- 4 bytes - 23.7.0.0 - header, magic_number, msg type, 0, 0
- 4 bytes - zone_index.0.0.0
- 32 bytes - random
- 32 bytes - sha256 hash
Dependencies
~2.3–3MB
~64K SLoC