DNS Server usando MySQL: MyDNS (Parte III y ultima)

por admin

Instalacion del interfaz Web para MyDNS

En los siguientes pasos se asume que estas usando Debian Sarge; el directorio root en Apache es /var/www por lo que instalaremos el interfaz web aqui. Usaremos como nobre de host ns1.example.com.

phpMyAdmin

phpMyAdmin ya habia sido instalado al principio cuando ejecutamos: (apt-get install mysql-server mysql-client libmysqlclient12-dev phpmyadmin), asi que debería ser accesible desde la url: http://ns1.example.com/phpmyadmin. Seleccionamos la base de datos mydns, y vemos las tablas rr y soa. Para una pequeña explicacion de la estructura y campos de la base de datos echa un viastazo aqui: http://mydns.bboy.net/doc/html/mydns_8.html#SEC8

El interfaz web original de MyDNS

Para instalar el interfaz web original de MyDNS (viene con las fuentes de MyDNS y deberia encontrarse en la carpeta /tmp), hacemos esto:

cp /tmp/mydns-1.0.0/contrib/admin.php /var/www

A continuacion editamos /var/www/admin.php y configuramos las variables en la primera parte del script, algo parecido a esto:

/*****************************************************************************
CONFIGURABLE OPTIONS
*****************************************************************************/
/*
** Set the following four variables to the hostname of your SQL server, the
** username and password used to access that server, and the name of the
** database where your MyDNS data resides.
*/
$dbhost = "localhost";
$dbuser = "mydns";
$dbpass = "mydns_password";
$dbname = "mydns";
/*
** This script uses MySQL by default. To use PostgreSQL instead, set
** '$use_pgsql' to '1'.
*/
$use_pgsql = 0;
/*
** The following two variables tell this script the name of your SOA
** table and the name of your RR table.
*/
$soa_table_name = "soa";
$rr_table_name = "rr";
/*
** The following two values configure the number of records shown per page
** in the zone browser and the resource record editor, respectively.
*/
$zone_group_size = 25;
$rr_group_size = 20;
/*
** This script can automatically update the serial number for a zone
** whenever a client modifies any record in that zone.
** Setting '$auto_update_serial' to '1' will enable this option.
*/
$auto_update_serial = 1;
/*
** This script can automatically update PTR records when you modify,
** add, or delete A records. To enable this functionality, set
** '$auto_update_ptr' to '1'. If you enable this, be sure to fill in
** the values for '$default_ns' and '$default_mbox', below, so that
** new SOA records will have the correct information.
*/
$auto_update_ptr = 1;
/*
** If this option is nonzero, this script will not complain if the
** TTL for a record is set below the zone minimum.
**
** Note that if $ttl_min below is nonzero, that value will still be
** checked.
*/
$ignore_minimum_ttl = 1;
/*
** The following values are used by this script to enforce minimum values
** for SOA and RR records. The script will prevent clients from entering
** values lower than these numbers.
*/
$ttl_min = 300;
$refresh_min = 300;
$retry_min = 300;
$expire_min = 86400;
/*
** The following two variables specify the default nameserver for new
** SOA records, and the default administrator mailbox for new SOA records.
** These will be filled in automatically whenever a new zone is created.
*/
$default_ns = "ns1.example.com.";
$default_mbox = "admin.example.com.";
/*
** The following array specifies default records for new SOA records.
** These get inserted automatically whenever a SOA is inserted.
** The format of each record is (name, type, aux, data).
*/
$default_records = array(
array("", "NS", 0, "ns1.example.com."),
/* array("", "MX", 10, "mail.example.com.") */
);
/*
** The following five values will be used as default values whenever new
** zones are created.
*/
$default_ttl = 86400;
$default_refresh = 28800;
$default_retry = 7200;
$default_expire = 604800;
$default_minimum_ttl = 86400;
/*
** The remainder of these variables enable cosmetic changes.
*/
$fontsize = 12; /* Default font size (pixels) */
$font_color = "#663300"; /* Font color */
$page_bgcolor = "white"; /* Page background color */
$help_bgcolor = "#FFFFCC"; /* Main screen help box background color */
$soa_bgcolor = "#FFFF99"; /* SOA editor background color */
$list_bgcolor_1 = "#FFFFCC"; /* List items #1 background */
$list_bgcolor_2 = "#FFFFAA"; /* List items #2 background */
$query_bgcolor = "#FFFFCC"; /* Search query input background color */
$query_fgcolor = "black"; /* Search query input font color */
$input_bgcolor = "white"; /* Text input box background color */
$input_fgcolor = "black"; /* Text input box font color */
/**** End of configurable options *******************************************/

Asegurate de introducir correctamente los detalles de la base de datos. Ademas establecemos $auto_update_serial y $auto_update_ptr a 1 y creamos los valores de $default_ns y $default_mbox para que incrementen automaticamente en caso de cambios y que los registros PTR sean creados automaticamente. Pero esto es opcional.

Ahora el interfaz web será accesible desde: http://ns1.example.com/admin.php.

Instalacion de MyDNSConfig

MyDNSConfig es un interfaz web an interface escrito enPHP. El interfaz original de MyDNS parece demasido complicado para usuarios no avanzados porque no tiene ningun tipo de descripcion de los campos (es mas facil para gente con conocimientos en Bind porque el diseño del interfaz es parecido a las organizacion de archivos de zona de Bind).

Puedes descargar MyDNSConfig desde http://www.mydnsconfig.org.

A continuacion, una vez descargado mydnsconfig-.tar.gz en /tmp lo instalamos asi:

tar xvfz mydnsconfig-.tar.gz
cd mydnsconfig
cp -fr * /var/www

Lo siguente será configurarlo, abrimos el archivo /var/www/lib/config.inc.php. Debería quedar algo asi:

ini_set('register_globals',0);
$conf["app_title"] = "MyDNSConfig";
$conf["app_version"] = "1.0.0";
$conf["rootpath"] = "/var/www";
$conf["fs_div"] = "/"; // File system divider, \\ on windows and / on linux and unix
$conf["classpath"] = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes";
$conf["temppath"] = $conf["rootpath"].$conf["fs_div"]."temp";
/*
Database Settings
*/
$conf["db_type"] = 'mysql';
$conf["db_host"] = 'localhost';
$conf["db_database"] = 'mydns';
$conf["db_user"] = 'mydns';
$conf["db_password"] = 'mydns_password';
/*
External programs
*/
//$conf["programs"]["convert"] = "/usr/bin/convert";
//$conf["programs"]["wput"] = $conf["rootpath"]."\\tools\\wput\\wput.exe";
/*
Themes
*/
$conf["theme"] = 'default';
$conf["html_content_encoding"] = 'text/html; charset=iso-8859-1';
$conf["logo"] = 'themes/default/images/mydnsconfig_logo.gif';
/*
Default Language
*/
$conf["language"] = 'en';
/*
Auto Load Modules
*/
$conf["start_db"] = true;
$conf["start_session"] = true;
/*
DNS Settings
*/
$conf["auto_create_ptr"] = 1; // Automatically create PTR records?
$conf["default_ns"] = 'ns1.example.com.'; // must be set if $conf['auto_create_ptr'] is 1. Don't forget the trailing dot!
$conf["default_mbox"] = 'admin.example.com.'; // Admin email address. Must be set if $conf['auto_create_ptr'] is 1. Replace "@" with ".". Don't forget the trailing dot!
$conf["default_ttl"] = 86400;
$conf["default_refresh"] = 28800;
$conf["default_retry"] = 7200;
$conf["default_expire"] = 604800;
$conf["default_minimum_ttl"] = 86400;
?>

Comprobamos los datos de configuracion de la base de datos para que todo este correcto, si queremos que MyDNSConfig cree automaticamente los registros DNS inversos (PTR records) cuado creas un nuevo registro DNS tenemos que establecer $conf['auto_create_ptr'] a 1 y especificamos un el servidor de nombres por defecto en $conf['default_ns'] (no olvidar el punto al fina) y una direccion de email de administrador en $conf['default_mbox'] (tambien con el punto al final, y la arroba @ debe ser reemplazada por un punto).

Ahora cambiamos la tabla rr y soa en la base de datos de mydns y creamos una nueva tabla necesaria por MyDNSConfig:

mysql -u root -p
Enter password:

Use mydns;

ALTER TABLE `rr` ADD `sys_userid` INT NOT NULL,
ADD `sys_groupid` INT NOT NULL AFTER `sys_userid`,
ADD `sys_perm_user` VARCHAR( 5 ) NOT NULL AFTER `sys_groupid`,
ADD `sys_perm_group` VARCHAR( 5 ) NOT NULL AFTER `sys_perm_user`,
ADD `sys_perm_other` VARCHAR( 5 ) NOT NULL AFTER `sys_perm_group`;

ALTER TABLE `soa` ADD `sys_userid` INT NOT NULL,
ADD `sys_groupid` INT NOT NULL AFTER `sys_userid`,
ADD `sys_perm_user` VARCHAR( 5 ) NOT NULL AFTER `sys_groupid`,
ADD `sys_perm_group` VARCHAR( 5 ) NOT NULL AFTER `sys_perm_user`,
ADD `sys_perm_other` VARCHAR( 5 ) NOT NULL AFTER `sys_perm_group`;

CREATE TABLE `sys_user` (
`userid` int(11) NOT NULL auto_increment,
`sys_userid` int(11) NOT NULL default ‘0′,
`sys_groupid` int(11) NOT NULL default ‘0′,
`sys_perm_user` varchar(5) NOT NULL default ”,
`sys_perm_group` varchar(5) NOT NULL default ”,
`sys_perm_other` varchar(5) NOT NULL default ”,
`username` varchar(100) NOT NULL default ”,
`passwort` varchar(100) NOT NULL default ”,
`modules` varchar(255) NOT NULL default ”,
`startmodule` varchar(255) NOT NULL default ”,
`app_theme` varchar(100) NOT NULL default ‘default’,
`typ` varchar(20) NOT NULL default ‘user’,
`active` tinyint(4) NOT NULL default ‘1′,
`name` varchar(100) NOT NULL default ”,
`vorname` varchar(100) NOT NULL default ”,
`unternehmen` varchar(100) NOT NULL default ”,
`strasse` varchar(100) NOT NULL default ”,
`ort` varchar(100) NOT NULL default ”,
`plz` varchar(10) NOT NULL default ”,
`land` varchar(50) NOT NULL default ”,
`email` varchar(100) NOT NULL default ”,
`url` varchar(255) NOT NULL default ”,
`telefon` varchar(100) NOT NULL default ”,
`fax` varchar(100) NOT NULL default ”,
`language` varchar(10) NOT NULL default ‘de’,
`groups` varchar(255) NOT NULL default ”,
`default_group` int(11) NOT NULL default ‘0′,
PRIMARY KEY (`userid`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `username`, `passwort`, `modules`, `startmodule`, `app_theme`, `typ`, `active`, `name`, `vorname`, `unternehmen`, `strasse`, `ort`, `plz`, `land`, `email`, `url`, `telefon`, `fax`, `language`, `groups`, `default_group`) VALUES (1, 1, 0, ‘riud’, ‘riud’, ”, ‘admin’, ‘21232f297a57a5a743894a0e4a801fc3′, ‘admin,designer,resellers,sites,dns’, ‘dns’, ‘default’, ‘admin’, 1, ”, ‘Administrator’, ”, ”, ”, ”, ”, ”, ”, ”, ”, ‘en’, ‘1,2′, 1);

quit;

Accedemos a MyDNSConfig a bajo http://ns1.example.com. El nombre de usuario por defecto es admin, y la contraseña admin. Puedes cambiar estos valores una vez que inicies sesion desde: System -> Edit user.

Comprobando nuestros Registros con dig.

Una vez creados los registros DNS con nuestro interfaz web podemos evaluarlos usando dig. Asumamos que hemos creado la zona test.com. (con el punto al final) registro A tipo www. Ejecutamos:

dig @localhost www.test.com

El resultado será algo asi:

:~# dig @localhost www.test.com
; <> DiG 9.2.4 <> @localhost www.test.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12658
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.test.com. IN A
;; ANSWER SECTION:
www.test.com. 86400 IN A 1.2.3.4
;; Query time: 20 msec
;; SERVER: 1.2.3.4#53(localhost)
;; WHEN: Fri Dec 16 14:14:19 2005
;; MSG SIZE rcvd: 45

Si activaste la creacion automatica de los registros PTR en el interfaz original de MyDNS en MyDNSConfig, tambien puedes comprobar los registros DNS inversos. Si www.test.com apunta a:1.2.3.4, entonces:

dig @localhost -x 1.2.3.4

será similar a esto:


~# dig @localhost -x 1.2.3.4
; <> DiG 9.2.4 <> @localhost -x 1.2.3.4
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46572
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;4.3.2.1.in-addr.arpa. IN PTR
;; ANSWER SECTION:
4.3.2.1.in-addr.arpa. 86400 IN PTR www.test.com.
;; Query time: 15 msec
;; SERVER: 1.2.3.4#53(localhost)
;; WHEN: Fri Dec 16 14:21:05 2005
;; MSG SIZE rcvd: 69

Esto es todo sobre MyDNS, proximamente se publicará un nuevo post sobre dnschache, ya que MyDNS no soporta DNS lookups externos. MyDNS solo responde peticiones para dominios propios. Es decir, si quieres que resuelva otros dominios como: www.google.com, deberas instalar un DNS resolver como dnscache en tu sistema, y debera ser instalado en una direccion IP separada.

Compartelo:
  • Meneame
  • BarraPunto
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
Relacionado:
DNS Server usando MySQL: MyDNS (Parte II)
DNS Server usando MySQL: MyDNS (Parte I)
Instalando LAMP
LAMP en openSuse

Responder