DNS-seeds

From PTS Wiki
Jump to: navigation, search


What?

Note: DNS seeds are not something that ordinary users need to bother about. The remainder of this page assumes a certain degree of technical knowledge regarding scripting, running automated services and in particular, providing authoritative DNS service.

The problem that all P2P networks face is - how does a new node find other nodes to connect to?

Various approaches exist, with varying degrees of centralization, like hardcoded IP addresses, IRC channels and DNS seeders. BitShares has until recently used hardcoded IP addresses, for example.

A DNS seeder monitors the network for publicly reachable nodes and publishes their IPs in the DNS. DNS itself is built for simplicity and reliability, and it is capable of providing redundancy at many levels. Ideally, we would have 2-3 domains controlled by different people, each pointing the "seed.<domain>" subdomain to several different nameservers. These nameservers should again be controlled by different people, each monitoring the network and creating their own list of IP addresses. Voila - multi-level redundancy with almost guaranteed instant connections for new nodes.

How?

The PTS source tree contains the map_pts_network program (slightly modified in comparison to upstream). In the PTS source tree,

make map_pts_network

Then, run this every thirty minutes from cron:

PORT=3703 # test network
#PORT=3777 # live network
GENESIS=libraries/blockchain/genesis.json
DOMAIN=pts-test.seed.quisquis.de # test network
#DOMAIN=pts.seed.quisquis.de # live network
DB=pts-test-seeds.db # test network
#DB=pts-seeds.db # live network
programs/utils/map_pts_network --port "$PORT" --genesis "$GENESIS" "$DOMAIN" 2>&1 | programs/utils/seeder.pl "$DB" "$PORT"


This will create a database in "$DB" of all nodes reachable on the default port, sorted by availability + reliability (highest first).

You'll need another script to take the (first 16 or so) IP addresses from $DB and feed them to your nameserver. For example for tinydns, this script could look like this:

echo ".${DOMAIN#*.}::<your-namserver>"
head -n 16 "$DB" |
  while read addr rest; do
    echo "+$DOMAIN:$addr:1800"
  done

If your setup is working, try to query your server from an external host:

dig a $DOMAIN @<your-nameserver>

You should receive a list of IP addresses, like this:

...
;; QUESTION SECTION:
;pts-test.seed.quisquis.de.     IN      A

;; ANSWER SECTION:
pts-test.seed.quisquis.de. 1800 IN      A       104.236.11.165
pts-test.seed.quisquis.de. 1800 IN      A       5.104.106.18
pts-test.seed.quisquis.de. 1800 IN      A       5.104.106.18
pts-test.seed.quisquis.de. 1800 IN      A       81.7.11.13
pts-test.seed.quisquis.de. 1800 IN      A       107.170.220.18
pts-test.seed.quisquis.de. 1800 IN      A       81.7.11.13

;; AUTHORITY SECTION:
...

If this works, contact us so we can delegate $DOMAIN to your nameserver.