Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

DNS explained – and manage zones with PHP

Thursday, July 28th, 2016 by Servage

internet-dnsDNS, the domain name system, is a system responsible for converting human-readable domain names into machine-readable IP addresses that translate to specific servers. This article explains the basics of the DNS system and gives an introduction to managing DNS zones using a PHP-powered website.

How DNS works

The domain name system is a big infrastructure that almost the whole Internet depends on. Every domain name on the Internet has one or multiple DNS servers that are responsible for the DNS zone of that domain. In a simplified form, the DNS zone is a file that contains key-value pairs called DNS records. These records are used to map hostnames to IP addresses. A hostname is the DNS record of a server, such as

Common types of DNS records

There are many types of DNS records for different purposes. The most common types are A, CNAME, MX and SOA records.
An A record is probably the most common. It maps a hostname to an IP address. For instance, points to 123.456.789.123.

CNAME is similar to an A record except that it points to another hostname. For example, points to (which then points to an IP).

MX stands for mail exchange. MX records define which server should handle email traffic for a domain name. A typical value for an MX record is “mail”, for example

SOA stands for start of authority, and it is a special type of record. It tells the domain name system what DNS server is the primary server for a domain name. It also contains other information, such as the email address of the domain administrator and how often the records should be refreshed by computers that are looking for those records.

Managing DNS records with PHP

Usually DNS records are managed directly on the DNS server. This is usually done by editing the configuration files manually using a text editor, which is not the only option though. If you have registered a domain name with a domain registrar or via Servage, you may have noticed the DNS zone manager on the control panel. It allows you to manage all the DNS records of your domain with a simple web interface.

If you are running your own DNS server, you could do the same on your own too! What you need is a DNS server software that supports storing DNS records in a database instead of a typical configuration file. A popular example of a DNS server that supports this is PowerDNS. If you load the DNS records from a database, you can easily update that information with MySQL queries in PHP. It takes some time and effort to get a system like this working, but once it is working, it will be great to have your own DNS management system embedded directly into your PHP web application in case you need to do frequent changes or dynamically wish to add/edit/remove hostnames!

Alternatively to running you own DNS for varying hostnames, you can also use the Servage DNS with a wildcard subdomain, which points to a PHP script that can handle different hostnames.

DNS explained - and manage zones with PHP, 4.3 out of 5 based on 3 ratings
Categories: Tips & Tricks

Keywords: ,

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.