---
title: "How to change the DNS provider to deSEC"
linkTitle: "Changing DNS provider to deSEC"
weight: 2
date: 2023-10-21
description: >
    For those who want to change their DNS provider after server installation.
---


We recommend using [deSEC](https://desec.io/) instead of [CloudFlare](https://cloudflare.com/). DeSEC is dedicated to privacy.

If you have first tied your domain to CloudFlare and now you want to change providers, this article is for you.

Attention, the process is quite complicated, and if you feel that something goes wrong, you can feel free to write us in the chat.

During this process, your services will be temporarily unavailable. Also, write down the IP address of your server, as you will not be able to access it by domain name.

## Transferring the nameserver

A nameserver is a server that translates your domain (letters) into a server IP address (numbers).

1. Register with [deSEC](https://desec.io/).

2. On [the "domains" page](https://desec.io/domains), click on the “plus” button.


{{< imgproc desec1 Fill "626x287" />}}


3. Enter your domain.

4. Copy "nameservers".

{{< imgproc desec2 Fill "626x287" />}}


Now go to the website of the domain registrar from whom you purchased the domain.
The actions will be similar for all providers, we will show using [Porkbun](https://porkbun.com/) as an example.

1. Go to your domain control panel.

2. Find there the “Authoritative nameservers” parameter.

{{< imgproc namechip1 Fill "626x287" />}}

3. Replace the current addresses with those that we copied from deSEC in the instructions earlier.

4. Save the changes.

{{< imgproc namechip3 Fill "626x287" />}}

---

## Getting the deSEC token

1. Log in [here](https://desec.io/login).

2. Go to the [Domains page](https://desec.io/domains).

3. Go to the **Token management** tab.

4. Click on the round "plus" button in the upper right corner.

{{< imgproc desec-tokenmanagment Fill "626x287" />}}

5. "**Generate New Token**" dialogue must be displayed. Enter any **Token name** you wish. Advanced settings are not required, so do not touch anything there.

6. Click on **Save**.

7. Make sure you save the token's "**secret value**" as it will only be displayed once.

{{< imgproc dncsec-copy Fill "626x287" />}}

8. Now you can safely **close** the dialogue.


---

## Migrating records


Log into both [CloudFlare](https://cloudflare.com/) and [deSEC](https://desec.io/).


### On the deSEC website

Follow [the link](https://desec.io/) in the “Domain Management” panel, click on your domain.

{{< imgproc howtodesec1 Fill "600x350" />}}

Now you can add new entries to it using the “Plus” button.

{{< imgproc howtodesec2 Fill "600x350" />}}


### On the CloudFlare website

Follow [this link](https://cloudflare.com/) and go to the settings of your domain, which is located under the "Websites" section.

Select your domain.

{{< imgproc howcloudflare2 Fill "363x442" />}}

Now go to "DNS", then "Records".

{{< imgproc howcloudflare Fill "363x442" />}}


### First record: api

Based on the example in the screenshot, transfer the parameters of your "api" record (look at the "Name" column) according to their colors.

{{< imgproc replace1 Fill "1544x755" />}}

On the left side of the screenshot is deSEC, and on the right side is Cloudflare. You need to sequentially transfer each parameter of this record.

### Second record: root

Create a new record of type "A", in the "IPv4 address" field, enter your server address, which you have already entered in the "Content" field of the previous record.

**You don't need to transfer all the records!** You have created two records, and the third one has already been created for you.

{{< imgproc replace2 Fill "1250x830" />}}

---


## Connecting to the server

To perform the following actions, you will need to connect to the server via SSH with administrator privileges. Basic understanding of the command line is recommended ;)

You can find instructions on how to connect [here](/docs/how-to-guides/root_ssh/).

After connecting to the server, enter the following command:

```
nano /etc/nixos/userdata.json
```

You are in a terminal text editor called "nano".

You are editing the file `/etc/nixos/userdata.json`, and you can use the arrow keys to navigate.

Find the following lines in the file:

```
"dns": {
    "provider": "CLOUDFLARE",
    "useStagingACME": false
},

```

Replace:

```"provider": "CLOUDFLARE",```

with

```"provider": "DESEC",```

Now press CTRL+X, and then key Y.

Then edit another file:

```
nano /etc/selfprivacy/secrets.json
```

Find the following:

```
"dns": {
    "apiKey": "SECRET-HERE"
},

```

Remove your old token from CloudFlare and paste the copied token from deSEC.
(If CTRL+V doesn't work, try SHIFT+CTRL+V)

```"apiKey": "Your deSEC token",```

It should now look like this:

```
"dns": {
        "apiKey": "Your deSEC token"
    },
```

Press CTRL+X, then Y to save the file.

If the file has been saved and you have successfully exited the text editor, enter the command:

```
systemctl start sp-nixos-rebuild.service
```

It will start the rebuild of your system with new options. You may close the console now.


---

## Reconfiguring the application

You will have to reset the application config to work properly. **Don't forget to create a recovery key and save it in a safe place (password manager).**

How to reset the application:

Go to Application Settings.

{{< imgproc app1 Fill "590x1221" />}}


Press "Reset application config".

{{< imgproc app2 Fill "585x700" />}}


Now go to the "Setup Wizard" section where you configured your server when you first launched the application.

{{< imgproc app3 Fill "590x1221" />}}

Tap "I already have a SelfPrivacy server!".

(In the old version it might be called "Connect to an existing server").

{{< imgproc app4 Fill "590x1221" />}}

Next, follow the instructions in the app and enter the recovery key or code from another device where the SelfPrivacy app is installed.

After installation, you will see some problems with Domain and DNS. The application will offer you to fix them. Accept the fixes.

{{< imgproc app5 Fill "590x1221" />}}


{{< imgproc app6 Fill "590x500" />}}



**Congratulations! You have successfully changed your domain provider. We recommend you to check that all services are working correctly.**
