DNS-over-HTTPS setup (DoH domain)
We have 2 ways to create a DoH domain:
1. Using your account dashboard
- Follow the instructions from our guide here to create a DoH URL link.
- Transform your DoH URL link into a DoH domain.
Simply place the token number before the doh.safedns.com domain
Example: DoH URL: https://doh.safedns.com/847593758 ➡️ DoH domain: 847593758.doh.safedns.com
2. Using Python code
Using Python code allows you to quickly create DoH domains for all your policy profiles.
- For Reseller accounts, it is possible to use our Subscriptions API guide to automatically create all the necessary policy profiles.
- End-user accounts can create policies manually using the SafeDNS Dashboard interface
- Once the policies are created, run the Python code to generate the corresponding DoH domains.
Here is the code you need to run in an environment that supports Python:
import requests
def get_token(login, password):
api_url = 'https://safedns.com/api/token/by-password/'
try:
response = requests.post(api_url, data={'username': login, 'password': password}, headers={'Content-Type': 'application/x-www-form-urlencoded'})
response.raise_for_status()
data = response.json()
return data.get('access')
except requests.exceptions.RequestException:
return None
def generate_links(tokens):
return [f"{token}.doh.safedns.com" for token in tokens if token is not None]
username = 'your_username' # Add your actual username here
password = 'your_password' # Add your actual password here
access_token = get_token(username, password)
if access_token:
api_url = "https://safedns.com/dashboard/rest_api/v1/users/111841/profiles/?page=1&page_size=1000" #Replace the ID after /users/ with your actual user_id
try:
response = requests.get(api_url, headers={'Authorization': f'Bearer {access_token}'})
response.raise_for_status()
data = response.json()
tokens = [item['token'] for item in data.get('results', []) if 'token' in item and item['token'] is not None]
result_links = generate_links(tokens)
for link in result_links:
print(link)
except requests.exceptions.RequestException:
print("Error fetching data.")
else:
print("Failed to obtain access token.")
Example of how to run the code in Google Colab:
- Open Google Colab.
- Select New Notebook.
- Insert the code.
- Modify lines 18, 19, and 24 in the code:
- Line 18: Enter your username.
- Line 19: Enter your password.
- Line 24: Enter your User ID (please contact technical support to obtain your User ID).
- Run the code
- After executing the code, the output will display a list of DoH domains for all your created policies.
Setting up DNS-over-HTTPS on Android
To configure DNS-over-HTTPS (DoH) on Android, follow these steps: