# VPN Node DNS Configuration

The SDK allows you to change the DNS server used by the VPN node to resolve DNS requests. You can configure either a predefined DNS server provided by the backend or specify a custom DNS server URL.

## Option 1: Use Predefined DNS (From Backend API)

To use a predefined DNS server configured by the backend, follow these steps:

1. Fetch the available DNS server from the backend using `sdk.getBackend().locations`.
2. Pass the DNS value to the `withNodeDns()` method.

```kotlin
sdk.getBackend().locations(ConnectionType.HYDRA_TCP, new Callback<AvailableLocations>() {
   @Override
   public void success(@NonNull AvailableLocations availableLocations) {
      //availableLocations.getDnsServers()[0]
      //builder.withNodeDns(NodeDns.custom(dns.getName())
   }

   @Override
   public void failure(@NonNull VpnException e) {
   }
}); 
```

* `getDnsServers()`: Retrieves the list of available DNS servers from the backend.
* `withNodeDns(NodeDns.custom(dns))`: Configures the VPN node to use the DNS server retrieved from the backend.

## Option 2: Use a Custom User-Defined DNS

Alternatively, you can define a custom DNS URL and pass it to the `withNodeDns()` method:

```kotlin
builder.withNodeDns(NodeDns.user("https://user.url/dns")
```

* `NodeDns.user()`: Allows you to specify a user-defined DNS URL that will be used for DNS resolution on the VPN node.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pango.gitbook.io/paas/sdk/vpn-sdk-for-android/features/vpn-node-dns-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
