2017 © Pedro Peláez
 

library dns

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

image

manie20/dns

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  • Monday, February 22, 2016
  • by netcode
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

DNS Library

This package contains modals and services used for mapping DNS Zone's and DNS records. It is used as a basic for the "manie20/rtr-dns-bundle" which offers the ability to manage Realtime Register DNS zones., (*1)

How to use?

Let's create a DNS zone by coding objects and output a string which can be used in a DNS zonefile., (*2)

use Netcode\Dns\Modal\Zone;
use Netcode\Dns\Modal\Domain;
use Netcode\Dns\Modal\Email;
use Netcode\Dns\Modal\Records\SOA;
use Netcode\Dns\Modal\Records\A;
use Netcode\Dns\Modal\Records\CNAME;
use Netcode\Dns\Service\ZoneFileService;

To start, let's create a new empty zone., (*3)

$zone = new Zone();

The SOA record is mandatory for a DNS zone and has all the zone file information. - Name contains the top-level domain for this zone. - Email address is converted to the zone administrative contact. - Nameserver is the server address the zone resided in. use 'ns' for the local nameserver. - SerialNumber is an incremental identifier for when the zone file has changes., (*4)

$soaRecord = new SOA();
$soaRecord
    ->setName(
        new Domain('netcode.nl')
    )
    ->setEmailAddress(
        new Email('a.krijgsman@netcode.nl')
    )
    ->setNameServer(
        new Domain('ns')
    )
    ->setSerialNumber(
        $soaRecord->getNewSerial()
    );

// Add the SOA Record to the newly created Zone.
$zone->setSoaRecord($soaRecord);

Now let's add some DNS records to the zone:, (*5)

$aRecord = new A();
$aRecord->setContent('127.0.0.1');
$zone->addRecord($aRecord);

$aRecord = new A();
$aRecord
   ->setName('www')
   ->setContent('127.0.0.1')
   ->setTTL(300);
$zone->addRecord($aRecord);


$cnameRecord = new CNAME();
$cnameRecord
    ->setName('mail')
    ->setContent('www')
    ->setTTL(7200);
$zone->addRecord($cnameRecord);

// And add the MX record:
$mxRecord = new MX();
$mxRecord
    ->setContent('mail')
    ->setPriority('10')
    ->setTTL(7200);
$zone->addRecord($mxRecord);

To test your fully populated zone, you can use the ZoneFileService to output the zone definition. If you feel this needs changes please contact me; I do not actually use it on a running nameserver., (*6)

$zoneFileService = new ZoneFileService();
$zoneFileService->getZoneText($zone)

Resulting in this output:, (*7)

netcode.nl. IN SOA ns a.krijgsman.netcode.nl. ( 2016013101 86000 7200 1209600 600 ) IN A 127.0.0.1 www 300 IN A 127.0.0.1 mail 7200 IN CNAME www 7200 IN MX 10 mail, (*8)

The Versions

22/02 2016

dev-master

9999999-dev

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

 

by Armand Krijgsman

31/01 2016

v1.0

1.0.0.0

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

 

by Armand Krijgsman

30/01 2016

v0.3

0.3.0.0

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

 

by Armand Krijgsman

29/01 2016

v0.2.1

0.2.1.0

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Armand Krijgsman

29/01 2016

v0.2

0.2.0.0

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Armand Krijgsman

29/01 2016

0.1

0.1.0.0

A collection of classes and services to maintain a PHP class representation of a DNS zone file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Armand Krijgsman