hsd icon indicating copy to clipboard operation
hsd copied to clipboard

node/dns: allow setting different public-host for root server

Open rithvikvibhu opened this issue 2 years ago • 5 comments
trafficstars

Currently, RootResolver gets the public-host config and this IP address is used when queried for root NS:

❯ dig . NS +nocomments

; <<>> DiG 9.16.1-Ubuntu <<>> . NS +nocomments
;; global options: +cmd
;.                              IN      NS
.                       85213   IN      NS     _g6cr3n0._synth.
;; Query time: 4 msec
;; SERVER: 127.0.0.50#53(127.0.0.50)
;; WHEN: Tue Mar 21 14:26:07 UTC 2023
;; MSG SIZE  rcvd: 68

Here, _g6cr3n0._synth. translates to the public IP of the node. While this works in most cases, when:

  • the node is a publicly reachable node, and
  • is running a private root server (bound to loopback)

then dig +trace breaks. When tracing, dig will try to query the root NS at the public IP which won't work since it is private.


I think we should have a new config option: ns-public-host which:

  • may (or not) be public
  • is passed to new RootResolver({publicHost: ...})
  • and is returned for dig . NS

Can confirm this change makes dig domain +trace work properly.

rithvikvibhu avatar Mar 21 '23 14:03 rithvikvibhu

isn't there rs-host and ns-host already?

pinheadmz avatar Mar 21 '23 14:03 pinheadmz

https://github.com/handshake-org/hsd/pull/630 ?

pinheadmz avatar Mar 21 '23 14:03 pinheadmz

Yes, ns-host defines what interface/IP to bind to. But the synth record that the NS responds with is for public-host which can be different from ns-host.

https://github.com/handshake-org/hsd/blob/6b47c3a023423552890aa0d3d780bf71659f5a3a/lib/dns/server.js#L139-L143

rithvikvibhu avatar Mar 21 '23 14:03 rithvikvibhu

hm ok i thought this in that context referred to the DNS server, so this.publicHost === server.publicHost === rs-host ?

pinheadmz avatar Mar 21 '23 14:03 pinheadmz

Currently,

  • config.publicHost == pool.publicHost == ns.publicHost
  • config.nsHost is only for NS binding
  • config.rsHost is only for RS binding

I think we need to replace the first one with:

  • config.publicHost == pool.publicHost
  • config.nsPublicHost == ns.publicHost (and maybe fallback to the old publicHost)

rithvikvibhu avatar Mar 21 '23 14:03 rithvikvibhu