> ## Documentation Index
> Fetch the complete documentation index at: https://docs.iroh.computer/llms.txt
> Use this file to discover all available pages before exploring further.

# DNS

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.

## Using DNS Discovery

DNS discovery is the default discovery mechanism in iroh, so you don't need to
do anything special to enable it.

[Number 0](https://n0.computer) provides a set of public DNS servers that are
free to use, and are configured by default. You're more than welcome to run
production systems using the public relays if you find performance acceptable.
The public servers do rate-limit traffic, there is no guaranteed uptime.

If you need more capacity or uptime guarantees or SLAs, you can
run your own DNS server, or [contact us about hosted DNS
options](https://cal.com/team/number-0/n0-protocol-services?overlayCalendar=true).

```rust theme={null}
use iroh::{Endpoint, endpoint::presets};
use iroh_tickets::endpoint::EndpointTicket;

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

    println!("endpoint id: {:?}", endpoint.id());

    let ticket = EndpointTicket::new(endpoint.addr());
    println!("Share this ticket to let others connect to your endpoint: {ticket}");

    Ok(())
}
```

To discover other endpoints over DNS, you can use an EndpointId or a [Ticket](/concepts/tickets) that contains
an EndpointId.

## Use your own 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.

Two nodes must connect to the same DNS discovery server to find each other using
DNS discovery.

TODO: rust code for custom dns server

## Disable DNS Discovery

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`.

```rust theme={null}
use iroh::Endpoint;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
      let endpoint = Endpoint::empty_builder().bind().await?;
      // your code here
      Ok(())
}
```

## Important notes

For more information on how DNS discovery works, see the [Discovery](/concepts/discovery) concept page.
