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.

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:

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.

Last updated