Tech-Talk

The Magic of a Blockchain DNS Seeder

4 Mins read

And why “AddNodes” a bad. Why are so few projects using the DNS node discovery? It’s easy as a pie!


I installed a new wallet and start it up… no connections to the blockchain…

Many have probably already experienced this and know it. Experienced cryptonauts know how to help themselves: “AddNodes.”
I look for known nodes in the blockchain and either add them to my wallet config file or (the better way to avoid the bad ones), I add them with a command via the debug console addnode "IP" "add|remove|onetry".

Why “add nodes” are bad

AddNodes are nothing more than wallet daemons in the blockchain network that are currently available.
In 5 minutes, they may not be available anymore (so it is terrible to put the static IP addresses in your wallet config file). If I close my wallet today and reopen it at a later time, I may face the same problem again.
Also, these known IP addresses are not verified. They work “somehow” at the moment.

Why a DNS seeder is better

A DNS seeder is a DNS server specially developed for the blockchain, which works like a “normal” DNS server.
What is a DNS server? But that’s not all. The main advantage of a seeder is that it regularly discovers the corresponding blockchain network and checks the discovered nodes (IP addresses) for function. Besides, it is possible to set the version protocol with which the wallet connection may be established. This can be used to prevent connections to old wallet versions.

Advantages of a DNS Seeder service

  • all nodes reached by the seeder are checked for function
  • only working nodes are published
  • you can control to which wallet versions are exposed
  • the client is provided with a bundle of addresses
  • two DNS seeder is entirely sufficient for a blockchain
  • no need to install a wallet daemon on the seeder server
  • the seeder service consumes minimal system resources (a few MB Ram and nearly zero CPU)
  • you will get a connection to the blockchain on every place on earth because the addresses are available from the global internet DNS
  • the configuration is straightforward

Technical deep dive: How works the node discovery in a blockchain network?

The Satoshi client discovers the IP address and port of nodes in several different ways.

  1. Nodes discover their own external address by various methods.
  2. Nodes receive the callback address of remote nodes that connect to them.
  3. Nodes make a DNS request to receive IP addresses.
  4. Nodes can use addresses hardcoded into the software.
  5. Nodes exchange addresses with other nodes.
  6. Nodes store addresses in a database and read that database on startup.
  7. Nodes can be provided addresses as command-line arguments
  8. Nodes read addresses from a user-provided text file on startup

The Bitcoin developers wrote an excellent article on how the node discovery works in detail. It’s unnecessary to copy and paste it. You can find it here. We will concentrate in this article on point number three.

Why not every blockchain project is using the DNS seeder when it’s so cool and easy?

My explanation: A lack of knowledge

Technical deep dive: How to setup a DNS Seeder Server

Prerequisites:
• basic knowledge of DNS and able to set up “NS” DNS records at your web hosting service
• ability to change a few lines of code
• basic knowledge of blockchain code
• have an IP4 and IPv6 configured on the VPS
• Linux VPS server (500 MB Ram, 1 CPU, 10 GB hard disk)
• in your codebase in chainparams.cpp you need to have a DNS name and access to this domain (i.e. vSeeds.push_back(CDNSSeedData("mycrypto.com", "seed01.mycrypto.com")

Note: A subdomain or a host looks for a DNS identically.

Download the source. Sipa from Bitcoin created the mother of the seeder: The “Sipa Seeder”. Here is the repository.

I will not write a cook book for you, but I will tell you what you have to change in the code.

• static const string mainnet_seeds[] = {“seed01.mycrypto.com”, “”};
• pchMessageStart[0-3] = 0x;
• define REQUIRE_VERSION 70001
• static const int PROTOCOL_VERSION = 70015;
• return testnet ? 1234 : 5678;

COMPILING

You will require boost and SSL. On Debian systems, these are provided by libboost-dev and libssl-dev, respectively.
No, we can make it: make
This will produce the ‘dnsseed’ binary.

DNS Configuration

I think this is for the most of all people the most significant obstacle (but it’s relatively easy). You have to do this work in the DNS management panel where your domain is hosted (domain and web service musn’t be hosted on the same service 😉 )

Example:

• create an “A” record from the VPS server IP
• create an “AAAA” record from the VPS server IP
• create an “NS” record with the name of your seed name (i.e., “seed01.mycrypto.com”) and point him to the A record from the VPS

This is the DNS magic configuration. It works with ALL DNS services in the whole world when you can configure “NS” entries! Note: Set the TTL to 300 seconds when you can.

Here a screenshot how it must look:

Run the Seeder!

Now it’s time to start the machine.

./dns-seeder/dnsseed -h seed01.mycrypto.com -n myvpsservername.mycrypto.com -m root.mycrypto.com

Test the service

Before you start the test, go for a beer or a coffee. Why? The distribution of the DNS entries just takes some time. How long? It depends on your hoster – one minute until 24 hours.

Here you can check your seeder service with IPv4 and IPv6. Put your values and test it.

https://www.whatsmydns.net/#A/s0.gossipcoin.org
https://www.whatsmydns.net/#AAAA/s0.gossipcoin.org


No efforts to setup your own? Use the DNS Seeder Service as Managed Service!

GOSSIP DNS Seeder

Conclusion

In this article, we have investigated all about DNS Seeders in great detail. Following the instructions, every technically experienced person should be able to install his seeder service for his blockchain. I am not talking about developers but intentionally about technically skilled people. For a software developer, this simple setup is no challenge. I am curious if the number of seeders in the projects will increase. Let’s wait and see.


Related posts
Tech-Talk

Check Your Shell Scripts with ShellCheck.net

1 Mins read
Check If Your Shell Script Code Sucks. For all Shell Ninjas and all who want to be one.
Tech-Talk

Wallet release versioning | Semantic Versioning

2 Mins read
What rules are there? How do you version software releases correctly? Semantic Versoning is the answer!
Tech-Talk

Iquidus Explorer Setup in 30 Minutes

5 Mins read
The ultimate installation guide for the Iquidus Block Explorer. There are no up-to-date and complete guides on the internet. Here the all…
×
Stake and Nodes

Masternode Project Statistics