2
0
mirror of https://github.com/namecoin/ncdns synced 2024-11-13 13:10:33 +00:00
Go to file
Jeremy Rand bed8c7d921
Merge namecoin/ncdns#158: Disable some unwanted Cirrus checks
37d7d99c50 Make "Modules Off" tasks non-mandatory until btcd is upgraded (Jeremy Rand)
9c7589d64f Suppress errchkjson false positive (Jeremy Rand)
7e46b7d256 Disable execinquery linter (Jeremy Rand)
1696838438 Mark nonamedreturns linter as non-mandatory (Jeremy Rand)
2c54918935 Disable exhaustruct linter (Jeremy Rand)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: b6435bd770864f2db51ca6ca391d327b2bfa12cf632bc61efa80fda8dfa78c8fd2e9ecdbc8357ac05a77e542b7a6c7fa3a229b318da6e24d4bf41173f0dcc543
2022-05-11 07:57:39 +00:00
_doc Refactoring for travis, make 2015-12-06 05:28:47 +00:00
_tpl/std Refactoring for travis, make 2015-12-06 05:28:47 +00:00
.travis Travis: Disable darwin/386 for Go 1.15+ 2020-11-22 16:07:03 +00:00
backend Explicitly suppress error returned by DomainValueHookTLS 2021-12-24 02:30:07 +00:00
certdehydrate Suppress errchkjson false positive 2022-05-11 07:27:39 +00:00
namecoin Fix NXDOMAIN detection 2019-12-16 20:33:25 +00:00
ncdomain Explicitly suppress error returned by parseImport 2021-12-24 02:22:53 +00:00
ncdt Switch to new rpcclient based on latest upstream Conformal 2019-10-27 13:39:43 +00:00
ncdumpzone ncdumpzone: Work around encoding errors 2019-10-27 19:37:29 +00:00
rrtourl ncdumpzone: Add mode for a URL list. 2019-02-27 22:20:09 +00:00
server Log HTTP server errors 2021-12-24 02:40:16 +00:00
testdata Cirrus: Fix error when GOPATH is unset 2021-06-17 04:41:08 +00:00
testutil more compliance 2014-12-08 06:07:07 +00:00
tlshook Use new certinject package 2021-12-15 16:28:59 +00:00
tlsoverridefirefox Switch to new rpcclient based on latest upstream Conformal 2019-10-27 13:39:43 +00:00
util Fix varnamelen warning in SplitDomainByFloatingAnchor 2021-12-24 01:34:54 +00:00
.cirrus.yml Make "Modules Off" tasks non-mandatory until btcd is upgraded 2022-05-11 07:40:36 +00:00
.golangci.yml Cirrus: Whitelist type assertions in varnamelen linter 2021-12-24 00:57:32 +00:00
.travis.yml Travis: Add Go 1.13.x, 1.14.x, 1.15.x 2020-11-22 14:14:34 +00:00
BorderlessBlockParty2015.md TLS dehydrated certificate injection for CryptoAPI trust store (triggered by hooking DNS lookups). 2017-07-28 02:26:40 +00:00
COPYING Add COPYING file (GPLv3) 2021-06-16 22:49:43 +00:00
main.go goimports -w main.go 2018-06-23 10:04:19 +00:00
Makefile Build: Makefile: move repo from hlandau/ncdns to namecoin/ncdns. 2017-08-08 05:57:57 +00:00
README.md Use new certinject package 2021-12-15 16:28:59 +00:00

ncdns

A Go daemon to bridge Namecoin to DNS. The daemon acts as an authoritative nameserver and queries a Namecoin daemon over JSON-RPC in order to obtain zone data.

The daemon can optionally sign zones with DNSSEC and supports the use of DS records in Namecoin. It works best when used by Unbound or another recursive resolver, or as an authoritative nameserver for a stub zone.

Using ncdns to provide a suffix

The daemon acts as an authoritative nameserver for any name containing a 'bit' label. For example, all of the following queries return the same records:

  • example.bit.
  • example.bit.example.com.

This enables the easy use of suffixes. (Note that this will cause a different hostname to be transmitted for protocols like HTTP, and server configuration may need to be modified to enable this. In some cases there may be no simple solution to enabling arbitrary suffix use with a given piece of server software, in which known suffixes can be configured; patches for such software would be desirable.)

Using ncdns with a recursive resolver

Of course the daemon can also be used simply as an authoritative nameserver for bit. directly. One way to do this is to run a recursive resolver (such as Unbound) and configure it to serve the zone as a 'stub zone'. Here is an example unbound configuration:

server:
  do-not-query-localhost: no
stub-zone:
  name: bit.
  stub-addr: 127.0.0.1@1153

If you don't want to use DNSSEC, also add:

server:
  domain-insecure: bit.

If you do want to use DNSSEC, see the instructions below.

Note how you can specify a port other than 53. This allows you to run both Unbound and ncdns on the same machine. Alternately, you could add an additional loopback IP address (127.0.0.2) and bind ncdns to that. This is useful if your recursive resolver doesn't support a port number other than 53.

Using DNSSEC

To use DNSSEC, generate keys with dnssec-keygen or ldns-keygen. You will need to generate a key-signing key and a zone-signing key:

# Generate KSK.
$ dnssec-keygen -a RSASHA256 -3 -b 2048 -f KSK bit

# Generate ZSK.
$ dnssec-keygen -a RSASHA256 -3 -b 2048 bit

Each of these commands will generate a pair of files, a .key file and a .private file. Make a note of which is the KSK and which is the ZSK. If you forget, check the comments inside the .key file. (If there are no comments for some reason, a KSK usually contains the string DNSKEY 256 and a ZSK DNSKEY 257.)

(You could substitute something else for bit as ncdns doesn't care. However if you want to use the key as a trust anchor with a recursive resolver such as unbound, you should specify bit.)

If using Unbound as a recursive resolver, you should add the KSK's public key file as a trust anchor to unbound like so:

server:
  trust-anchor-file: "/etc/unbound/keys/bit.key"

bit.key should be the file containing the KSK DNSKEY (or DS) which ncdns is configured to use.

Building

Prerequisites:

  1. Ensure you have the Go tools installed.

  2. If using Linux, ensure you have the libcap development headers installed. (Most distributions will have a package called libcap-dev or similar.)

Option A: Using Go build commands without Go modules (works on any platform with Bash; only Go 1.15-1.16.x; will not work on Go 1.17+):

  1. Ensure you have the GOPATH environment variable set. (For those not familar with Go, setting it to the path to an empty directory will suffice. The directory will be filled with build files.)

  2. Run export GO111MODULE=off to disable Go modules.

  3. Run go get -d -t -u github.com/namecoin/ncdns/.... The ncdns source code will be retrieved automatically.

  4. Run go generate github.com/namecoin/certinject/.... The ReactOS property list will be parsed.

  5. Run go generate github.com/namecoin/x509-compressed/.... The compressed public key patch will be applied.

  6. Run go get -t -u github.com/namecoin/ncdns/.... ncdns will be built. The binaries will be at $GOPATH/bin/ncdns.

Option B: Using Go build commands with Go modules (works on any platform with Bash; Go 1.15+:

  1. Clone certinject, x509-compressed, and ncdns to sibling directories.

  2. Install certinject according to its instructions.

  3. Install x509-compressed according to its "with Go modules" instructions.

  4. Run the following in the ncdns directory to set up Go modules:

    go mod init github.com/namecoin/ncdns
    go mod edit -replace github.com/coreos/go-systemd=github.com/coreos/go-systemd/v22@latest -replace github.com/namecoin/certinject=../certinject -replace github.com/namecoin/x509-compressed=../x509-compressed
    go mod tidy
    
  5. Run go install ./.... ncdns will be built. The binaries will be at $GOPATH/bin/ncdns.

Option C: Using Makefile (non-Windows platforms):

  1. Run make. The source repository will be retrieved via go get automatically.

ncdns can be run as a Windows service; see the output of ncdns --help.

Configuration

ncdns uses a configuration file which is looked for at ../etc/ncdns.conf (relative to the executable path) and /etc/ncdns/ncdns.conf. You can override this and all options on the command line. An annotated example configuration file ncdns.conf.example is available in doc.

You will need to setup a namecoind, namecoin-qt or compatible Namecoin node and enable the JSON-RPC interface. You will then need to provide ncdns with the address of this interface and any necessary username and password via the configuration file.

If you only want to resolve .bit names yourself, here is a suggested setup on Linux:

  • Install namecoind (or namecoin-qt) and set it to start automatically at boot or login. Set up the JSON-RPC interface and make sure it works by making a test query: namecoind name_show d/example.

  • Write a ncdns configuration file and set ncdns up to start at boot. Since Unbound will tie up port 53, set a different port (ideally one >=1024, so it needn't be run as root.) Test that ncdns works by trying to resolve a .bit domain. If you want to use DNSSEC, generate keys as shown above and configure ncdns appropriately.

  • Install and setup the Unbound recursive resolver on your system. On most systems, the recommended way to install Unbound is to install DNSSEC Trigger, which installs and configures Unbound automatically.

    If you wish to use DNSSEC, add the ncdns DNSKEY to Unbound as a trust anchor as shown above. See above for configuration suggestions.

  • Edit /etc/resolv.conf to point to the Unbound resolver at 127.0.0.1. (If this file is generated automatically via DHCP or similar, you may find these changes keep getting wiped out. Either reconfigure whatever keeps overwriting it to stop doing so, or, as a stopgap measure, make the file immutable using chattr +i.)

Licence

Licenced under the GPLv3 or later.
© 2014-2015 Hugo Landau <hlandau@devever.net>