Import DNS data from a zone file

By using our PHP script, you can import a zone file into Glesys DNS.


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.

Once downloaded, log in to the control panel and create an API key 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.

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

The output will resemble this:

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.

Example of what a zone file looks like

A zone file looks something like this:

Last updated

Was this helpful?