> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/connectivity/domains-and-dns/how-tos/import-dns-data-from-a-zone-file.md).

# Import DNS data from a zone file

***

If you migrate your domains from another provider or if you have previously managed your own name servers, there is a high likelihood that all the records for those domains are stored in zone files.

Here, we'll show you how to automate the import of the data from those zone files into our system using a script.

## Import DNS records from a zone file

Glesys’s DNS backend does not use zone files, but we have a nice API that allows data import. Below is a PHP example showing how to use a script to import your zone file.

[Download the PHP file here.](https://assets.ctfassets.net/p9j0clqy0yel/6AEYWHzOQbaI4GiPFES4lZ/5ef8f1499eed0ff50f60aca7c5732475/php_glesys_zone_import.php.txt)

Once downloaded, log in to the control panel and create an [API key](/platform/control-panel/api.md) that has DNS permissions.

Once you have the PHP file and an API key in place, import the zone file by running the command below. Note that the script requires PHP 5.6 and the PHP cURL module to work. If you have multiple versions of PHP installed, replace `php` with `php5.6` in the command below.

{% code title="Command" %}

```
php php_glesys_zone_import.php <ZONEFILE> <USER> <API-KEY>
```

{% endcode %}

The output will resemble this:

{% code title="Output" %}

```
Log: Adding domain...
Log: Successfully added domain
Log: Adding 8 records...

Log: --- Summary ---
Log: A       4
Log: NS      2
Log: MX      1
Log: CNAME   1
Log: Total   8
Log: 0 failed.
```

{% endcode %}

## Example of what a zone file looks like

A zone file looks something like this:

{% code title="Example zone file" %}

```
$TTL    86400
$ORIGIN example.com.
@  1D  IN  SOA ns1.example.com. hostmaster.example.com. (
                              2002022401 ; serial
                              3H ; refresh
                              300 ; retry
                              1w ; expire
                              3h ; minimum
                             )
       IN  NS     ns1.example.com. ; in the domain
       IN  NS     ns2.smokeyjoe.com. ; external to domain
       IN  MX  10 mail.another.com. ; external mail provider
ns1    IN  A      192.168.0.1  ;name server definition
www    IN  A      192.168.0.2  ;web server definition
ftp    IN  CNAME  www.example.com.  ;ftp server definition
```

{% endcode %}


---

# 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://docs.glesys.com/products/connectivity/domains-and-dns/how-tos/import-dns-data-from-a-zone-file.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.
