Tim Igoe's Web Design, Development and Hosting Blog

Blog > MyDNS - DNS Hosting made really easy!

Do you have your own server and want to run your own DNS Server to control your domain yourself, but got confused with Bind 'zones' and configuration?

A few years ago I found a perfect solution, that allowed me to develop a back end for simple management through PHP that I could give to anyone to manage their own domain without requiring a degree in DNS! That DNS server was MyDNS ( http://mydns.bboy.net/ ). If like me, and you run an RPM based distro on your server (CentOS, Redhat, Fedora etc) then installation is a breeze.


wget http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
rpm -Uvh mydns-mysql-1.1.0-1.i386.rpm


Following this, you will need to create a MySQL database, I will assume you've already got MySQL database server installed and working.

Create a database table using whichever method you prefer, I called my dnsserver.

Within this, we now need to create 2 tables.


CREATE TABLE IF NOT EXISTS `domains` (
  `id` int (10) unsigned NOT NULL auto_increment,
  `domain` varchar (150) NOT NULL default '',
  `origin` varchar (150) NOT NULL default '',
  `ns` varchar (150) NOT NULL default '',
  `mbox` varchar (150) NOT NULL default '',
  `serial` int (10) unsigned NOT NULL default '1',
  `refresh` int (10) unsigned NOT NULL default '28800',
  `retry` int (10) unsigned NOT NULL default '7200',
  `expire` int (10) unsigned NOT NULL default '604800',
  `minimum` int (10) unsigned NOT NULL default '86400',
  `ttl` int (10) unsigned NOT NULL default '86400',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `dns` (
  `id` int (10) unsigned NOT NULL auto_increment,
  `zone` int (10) unsigned NOT NULL default '0',
  `name` char (50) NOT NULL default '',
  `type` enum ('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') NOT NULL default 'A',
  `data` char (100) NOT NULL default '',
  `aux` int (10) unsigned NOT NULL default '0',
  `ttl` int (10) unsigned NOT NULL default '86400',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `zone` (`zone`,`name`,`type`,`data`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


The 'domains' table lists the domains in the system, the important fields in this table are domain, origin, ns, mbox and serial. Domain, is the domain, excluding www. etc so 'igoe.me.uk', origin is the same as domain, but with a trailing . e.g. 'igoe.me.uk.', ns will be the name of the primary nameserver which can be within the domain your setting up and finally, serial is a timestamp to show the last update of the domain, the preference for these is YYYYMMDDXX Where XX is the update on that day, so starting 01 and incrementing every time its changed on that day.

With this row added, you will get an ID - this ID is then used in the second table to create the dns entries themselves, this is the 'zone'. Along with this the name, type and data will need to be filled in. For MX (Mail Exchanger) records you will need to fill in Aux too, to control the order that MX records are used.

A type records are to point an entry directly to an IP address.
CNAME records allow you to point an entry to another entry or address completely, so if you update one, you update the other automatically.
MX entries are Mail Exchangers, this is where email is sent and can be a different target to the A records.
NS are name server entries, you need to specify your name servers for your domain.

With this simple guide, you should be able to set up your own custom DNS server on your dedicated server. Having your own DNS server looks more professional, and gives you a lot more control over your domains.

Post a reply