Skip to main content
By Default, iroh uses the DNS discovery system to find other peers with a given EndpointId. iroh will use a standard DNS server to publish and resolve EndpointIds to their home relay addresses. This allows any iroh endpoint to be discoverable globally, as long as they are connected to the same relay that is reachable from the public internet.
use iroh::Endpoint;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let endpoint = Endpoint::bind().await?;

    println!("endpoint id: {:?}", endpoint.id());
    Ok(())
}
To discover other endpoints, you can use an EndpointId or a Ticket that contains an EndpointId.

Dedicated DNS Server

By default, iroh will look up the endpoint on a public shared instance of the DNS discovery server. If you’d like to run your own private DNS discovery server for more guaranteed privacy and uptime guarantees, you can configure iroh to use it. TODO: rust code for custom dns server

Important notes

  1. DNS discovery is the default discovery mechanism in iroh, so you don’t need to do anything special to enable it.
  2. DNS discovery only publishes the home relay of an endpoint, not its direct addresses.
  3. DNS discovery is opt-out, so if you don’t want your endpoint to be discoverable via DNS, you can disable it by using the Endpoint::empty_builder method instead of Endpoint::builder.
  4. Two nodes must connect to the same DNS discovery server to find each other using DNS discovery.
For more information on how DNS discovery works, see the Discovery concept page.