Archive for category Technical

geodns-new.pl

modified the geodns.pl from the original setup. Most of the file is still largely the same as the original. Added in some functions to support the new views management functions and modified the old ones to support weight configuration.

geodns-new.pl

30/10/2009: Updated the file link, no change in content though.

web UI

Finally publishing the web UI.

This is a PHP script, hence, PHP need to be installed on the server. PHP 5 to be exact

The database configuration can be done by modifying the variables in sql.php

 

Web UI

Configuration Download Script

to automate the comparison and download process of the generated configuration file (from WebUI), the following shell script could be used.

simply replace the following to use the script.

filePath="/var/named/downloaded.views"; #change the filepath to the destination file desired.

replace all http://12.7.0.0.1 with the location where the webUI is hosted.

 

getConfig.sh

database countries

To populate the countries in the geoip_geo table, the following file can be used to insert all countries available in the GeoLite Country database into the table.

geoip_geo is used to provide the countries available for matching to views.

databsae-geoip-countries.sql

database schema (upgrade)

If the database were already containing the old table. Perform the following to upgrade the database

update releases-geo using the upgrade file
    [jiajun@sm-geodnssoc ~]$ mysql -u user -p geo-mozilla-com< database-upgrade.sql

create the new tables and stored procedures
    [jiajun@sm-geodnssoc ~]$ mysql -u user -p geo-mozilla-com< database.sql

rebuild the views either from geodns.pl/web UI/mysql before restarting the DNS server
    [jiajun@sm-geodnssoc ~]$ mysql –u user –p
    mysql> call buildViews();

 

database-upgrade.sql

database.sql

database schema

Uploading the database schema. To create the MySQL DB for Bind’s usage, simply create and database and use the file to create the tables and stored procedures.

Example.

[jiajun@sm-geodnssoc ~]$ mysql –u user –p
mysql> CREATE DATABASE `geo-mozilla-com`;
mysql> exit
[jiajun@sm-geodnssoc ~]$ mysql -u user -p geo-mozilla-com< database.sql

rebuild the views either from geodns.pl/web UI/mysql before restarting the DNS server
    [jiajun@sm-geodnssoc ~]$ mysql –u user –p
    mysql> call buildViews();

NOTE: I had reuploaded the schema file on 5 Aug 2337 hrs (GMT +8).

Changes:

- the new version does not drop the table if it exists. It will create the table only if it does not exists. However, stored procedures will always be recreated.

 

Files:

Database Schema

Generated Diff

finished testing the diff file yesterday.

Downloaded bind-9.4.3-P3.tar.gz and made sure the codes work against it and the generated the patch by comparing the original files with the modified ones.

The diff included modifications to enable the dlz driver so that the vanilla codes can be changed without much intervention.

To replicate the results, the instructions are as follows:

  • download bind-9.4.3-P3.tar.gz
  • download mysql-bind.tar.gz
  • copy bind-9.4.3-P3.tar.gz to <Base Directory>
  • copy mysql-bind.tar.gz to <Base Directory>
  • cd <Base Directory>
  • tar -zxvf bind-9.4.3-P3.tar.gz
  • tar -zxvf mysql-bind.tar.gz
  • patch -p0 < ../allpatch.diff
  • cd bind-9.4.3-P3/bin/named/
  • ln -s ../../../mysql-bind/mysqldb.c mysqldb.c
  • cd include/named/
  • ln -s ../../../../../mysql-bind/mysqldb.h mysqldb.h
  • cd <Base Directory>/bind-9.4.3-P3
  • ./configure  –disable-openssl-version-check CFLAGS="-I/usr/local/include/" LDFLAGS="-L/usr/local/lib -lGeoIP"
  • make
  • sudo make install

The software requirements before the software to compile is that the geoIP API must be installed.

The files:

- Bind 9.4.3-P3

- MySQL-BIND DLZ

- THE patch:

Config Gen

completed the prototype of the configuration generator so that it can be used to update Bind.

When a new zone A.K.A domain is added, or a new view is added, the configuration file for Bind must be changed in addition to storing the records in the database. Otherwise, Bind would simply not know of their existence.

What the configuration generator does is to generate the configuration file based on the views that should be available and add the zones in the database to the view. Very view configuration will have the same set of zones, except that the zones in different views would look up different database table to use records configured for different region or country.

The last but important configuration would be the match statement. It provides the interface to the geoip elements. In summary, matching the ip of the client to the country. E.g. all ip from Australia would use the view that matches country_AU.

The PHP script would then be able to output the configuration in the HTML format for display, with all the menus and links etc. Or, it could output in text file format so that the output can be easily downloaded to the server (wget or curl). The MD5 will also be available.

configgen

To allow the “match” to be stored in database, i loaded all the possible country from geoip’s database into a table in the database. By using a join table to join the viewname to the countryname, the web ui now knows which view would match which country. The join table is used instead of simply adding a column so that a single view can match multiple countries.

22 July 2009

can’t wait to put these stuff into real use. :-)

Trying to validate the code as much as i can. The Bind portion seems fine.

managing views in WebUI

Over the last few days, i added the functionality to manage the views using the Web UI.

And of course, more bug shooting. The record data was not validated before forming the sql query, allowing things like empty rdata. Fixed this one.

webui-viewpage