Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNSSEC setup for dnsseed #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

DNSSEC setup for dnsseed #85

wants to merge 1 commit into from

Conversation

Emzy
Copy link

@Emzy Emzy commented Oct 7, 2020

Documentation to run a bind9 with DNSSEC in front of the bitcoin-seeder

README-dnssec.md Show resolved Hide resolved
README-dnssec.md Show resolved Hide resolved
README-dnssec.md Outdated Show resolved Hide resolved
README-dnssec.md Outdated Show resolved Hide resolved
README-dnssec.md Outdated Show resolved Hide resolved
README-dnssec.md Show resolved Hide resolved
README-dnssec.md Outdated Show resolved Hide resolved
contrib/dnsupdate Show resolved Hide resolved
README-dnssec.md Show resolved Hide resolved
README-dnssec.md Outdated Show resolved Hide resolved
@Emzy
Copy link
Author

Emzy commented Oct 30, 2020

@ysangkok thank you for the review. Very appreciated.
I'm still learning to use Github. So I hope I did it all right.

@Sjors
Copy link
Contributor

Sjors commented Mar 10, 2023

@Emzy just noticed this PR :-) Can you rebase the PR on top of master, and also squash the commits with duplicate names?

@Emzy
Copy link
Author

Emzy commented Mar 10, 2023

Just did that. Looks like it was already rebased to master.

@Sjors
Copy link
Contributor

Sjors commented Mar 10, 2023

@Emzy after a rebase there shouldn't be a commit [Merge branch 'sipa:master' into master] left though.

@Emzy Emzy force-pushed the master branch 2 times, most recently from 0436cae to 8dc1a6a Compare March 10, 2023 15:24
@Emzy
Copy link
Author

Emzy commented Mar 10, 2023

Sorry, I'm still try to master git.
I think I got it now into the right state.

@Sjors
Copy link
Contributor

Sjors commented Mar 10, 2023

That worked. But to further improve your mastery, try git rebase -i HEAD~5, and then replace pick with fixup for the second line (it should run hourly). That'll squash it into the first commit. You can also try Github Desktop which just lets you drag one commit into another.

@Emzy
Copy link
Author

Emzy commented Mar 10, 2023

Did exactly that. As a console user I prefer the git command line.

@Sjors
Copy link
Contributor

Sjors commented Mar 10, 2023

Ok, might as well also squash 2bf3b63 in it, because:

  1. it touch a file that is new in this PR
  2. having it as a separate commit doesn't aid review, nor does it help later in debugging

b7b80ac makes (slightly) more sense as it's own commit, because the commit message explains the purpose of that line (which shows up in git blame)

I would squash 2d6a09c into the first commit, because the end result is more readable than the initial thing. So if I review a PR one commit at a time, I have to study the grep stuff, only to see it disappear a few commits later.

(I'd probably just squash this entire PR into one commit, but the above illustrates my thinking on commits)

@Emzy
Copy link
Author

Emzy commented Mar 10, 2023

I agree, it makes sense to have it as just one commit.
Your guidance is very appreciated.

Copy link
Contributor

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So compared to the regular setup, we no longer forward (private) port 5353 to (public) port 53, and instead rely on the bind9 software? If so, you should mention that the PREROUTING step in the README should be skipped / undone.

If I understand the dnsupdate script correctly it only makes one call to the seeder. And the cronjob only runs that script hourly. So we'd end up with a very limited set of results (the seeder gives a differente result every time you call it). Could we instead run it every (couple of) seconds? Or bypass using dig and get the full (sorted) list directly?

When running the script manually I get update failed: SERVFAIL.

This is what it's trying to give to nsupdate -v:

server localhost
zone seed.bitcoin.sprovoost.nl
update delete seed.bitcoin.sprovoost.nl a
update delete seed.bitcoin.sprovoost.nl aaaa
update add seed.bitcoin.sprovoost.nl. 3600 A 80.121.88.109
...
update add seed.bitcoin.sprovoost.nl. 3600 AAAA 2a01:e0a:9:d30:2d6e:4e7f:455c:4b5
send

echo update delete ${ZONE} a
echo update delete ${ZONE} aaaa
for proto in A AAAA ; do
dig +noall +answer -t ${proto} -p 15353 @52.37.101.214 ${ZONE} | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IP here is replaced with where the seeder is running at?

Same below.

Can you the port, IP and domain a variable that's passed in an argument? That's more consistent the seeder command and easier when you have multiple seeds running on the same machine (mainnet, testnet, etc).

## Software needed

* Debian GNU/Linux 10
* tor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can drop Tor, because seeds were only able to announce Tor v2 addresses.

```
querylog no;
allow-transfer { none; };
dnssec-enable yes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


* Check config
```
named-checkconf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complains /etc/bind/named.conf.local:14: option 'auto-dnssec' is deprecated

* Check config
```
named-checkconf
named-checkzone dnsseed.example.com /var/lib/bind/db.dnsseed.example.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the expected result of this?

$ named-checkzone seed.bitcoin.sprovoost.nl /var/lib/bind/db.seed.bitcoin.sprovoost.nl 
/var/lib/bind/db.seed.bitcoin.sprovoost.nl:3: ignoring out-of-zone data (dnsseed.example.com)
/var/lib/bind/db.seed.bitcoin.sprovoost.nl:11: ignoring out-of-zone data (dummy)
zone seed.bitcoin.sprovoost.nl/IN: has 0 SOA records
zone seed.bitcoin.sprovoost.nl/IN: has no NS records
zone seed.bitcoin.sprovoost.nl/IN: not loaded due to errors.

Copy link
Contributor

@Sjors Sjors Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I got rid of the remaining dnsseed.example.com

But that leaves:

/var/lib/bind/db.seed.bitcoin.sprovoost.nl:11: ignoring out-of-zone data (dummy)
zone seed.bitcoin.sprovoost.nl/IN: NS 'seed.bitcoin.sprovoost.nl' has no address records (A or AAAA)
zone seed.bitcoin.sprovoost.nl/IN: not loaded due to errors.

```

* Restart Bind9
`service bind9 restart`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to succeed, though startup will have the same errors/warnings as above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have accidentally deleted this service, but this still works: sudo systemctl restart named

* Generate DNSSEC keys
```
cd /var/lib/bind
dnssec-keygen -r /dev/urandom -a ECDSAP256SHA256 dnsseed.example.com`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

` at the end?

Also:

dnssec-keygen: fatal: The -r option has been deprecated.
System random data is always used.

};
```

* /var/lib/bind/db.example.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean /var/lib/bind/db.dnsseed-host.example.com or does this have to one level up?

@Sjors
Copy link
Contributor

Sjors commented Aug 21, 2023

I also noticed that compared to the tutorial you're not adding a Zone Signing Key(ZSK). (nvm, you are, but not using the terminology)

Update: I think it works now, I had to use the hostname in one place - see above.


* Sign zone
```
dnssec-signzone -A -3 $(head -c 1000 /dev/random | sha1sum | cut -b 1-16) -N INCREMENT -o example.com -t db.example.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean -o dnsseed.example.com -t db.dnsseed.example.com or really the root domain?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also my bind9 seems to insist that the signed output is in raw format, so adding -O raw

```
$ORIGIN .
$TTL 3600 ; 1 hour
dnsseed.example.com. IN SOA dnsseed-host.example.com. contact-email.example.com. (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I overlooked the -host bit here.

@Sjors
Copy link
Contributor

Sjors commented Aug 21, 2023

It was a bit of a struggle to get all the key files in the right place. Not sure if I did it correctly, but at least this looks good:
Scherm­afbeelding 2023-08-21 om 19 36 47

I ended up putting all the keys in /etc/bind and also set key-directory "/etc/bind"; to that. All files there are owned by root:bind. Otherwise I kept getting errors that it wasn't finding this or that (private) key.

I used some cron-hack to make it update every 15 seconds, which is hopefully good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants