Results 1 to 10 of 18

Thread: Bind+DLZ+MySQL Hardy

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Cool Bind+DLZ+MySQL Hardy

    Hi Guys,

    Im not sure if its a run of bad luck on my part but try as i might finding doco on how to get DLZ running with a MySQL backend on hardy is impossible - Is anyone able to give me a hand to get this setup and running on a hardy server?

    Cheers,

    Kahn

  2. #2
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Bind+DLZ+MySQL Hardy

    I take it this is either a, exceptionally easy and im being a blind halfwit or well you know the rest

    I would be most gratefull for any assistance in this

    Kahn.

  3. #3
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Bind+DLZ+MySQL Hardy

    Nobody at all? Perhaps I posted this in the wrong place =\

  4. #4
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Bind+DLZ+MySQL Hardy

    Bump bump - I take it no one has had to configure this on a ubuntu host?

  5. #5
    Join Date
    Apr 2008
    Beans
    6

    Talking Re: Bind+DLZ+MySQL Hardy

    I got this up and running yesterday. It requires rebuilding the bind9 package.

    Make a temporary holding directory - I use /usr/local/src for this. From that directory, download the source for the bind9 package. Also, make sure the fakeroot and bison packages are installed.

    Code:
    mkdir -p /usr/local/src/bind9
    cd /usr/local/src/bind9
    apt-get install fakeroot bison
    apt-get source bind9
    This will bring the bind9 source into the bind9-9.4.2 directory. Inside there, edit the debian/rules file.

    Code:
    vi bind9.9.4.2/debian/rules
    Look for the section starting with "configure-stamp:". You'll be adding a flag to the commandline - I added a backslash to the last option, and added --with-dlz-mysql on the next line.

    Code:
        ./configure --prefix=/usr \
            --mandir=\$${prefix}/share/man \
            --infodir=\$${prefix}/share/info \
            --sysconfdir=/etc/bind \
            --localstatedir=/var/run/bind \
            --enable-threads \
            --with-libtool \
            --enable-shared \
            --enable-static \
            --with-openssl=/usr \
            --with-gnu-ld \
            --enable-ipv6 \
            --with-dlz-mysql
    Save and exit the file.

    Now you'll need to build the new package. From the bind9-9.4.2 directory, run the dpkg-buildpackage command:

    Code:
    dpkg-buildpackage -rfakeroot -b
    Once it finishes compiling (it'll take around 5 minutes or so), you can install the packages. Back up one directory and run ls. You'll see a bunch of packages there ending in .deb.

    Install all these packages to install your new bind9:

    Code:
    dpkg -i *.deb
    Now you're set with bind9 installed. Now you can configure it to use DLZ.

    cd into /etc/bind9. Edit your named.conf.options file and put your upstream provider's DNS servers into the forwarders section:

    Code:
        forwarders {
            1.2.3.4;
            5.6.7.8;
        };
    You can add as many DNS servers in there as you need, but two should suffice. Save and exit the file, then edit the named.conf.local file. Add this to the bottom:

    Code:
    dlz "Mysql zone" {
       database "mysql
       {host=127.0.0.1 dbname=db_name user=db_user pass=db_pass}
       {select zone from dns_records where zone = '%zone%'}
       {select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') when lower(type) = 'soa' then concat_ws(' ', data, resp_person, serial, refresh, retry, expire, minimum) else data end from dns_records where zone = '%zone%' and host = '%record%'}";
    };
    Change the information on the third line to match that of the MySQL database, username and password you'll be using. Save and exit this file.

    Log in to MySQL and create the database and user you want to use.

    Code:
    create database db_name;
    grant all privileges on db_name.* to db_user@localhost identified by 'db_pass';
    Create the table you'll need for the DNS records. Change the resp_person default to the email address of the person responsible for the DNS server (probably you) in the format of username.domain.com - the @ becomes a period. Change the primary_ns to the name of your nameserver, ie. ns1.yourdomain.com.

    Code:
     CREATE TABLE `dns_records` (
      `id` int(11) NOT NULL auto_increment,
      `zone` varchar(64) default NULL,
      `host` varchar(64) default NULL,
      `type` varchar(8) default NULL,
      `data` varchar(64) default NULL,
      `ttl` int(11) NOT NULL default '3600',
      `mx_priority` int(11) default NULL,
      `refresh` int(11) NOT NULL default '3600',
      `retry` int(11) NOT NULL default '3600',
      `expire` int(11) NOT NULL default '86400',
      `minimum` int(11) NOT NULL default '3600',
      `serial` bigint(20) NOT NULL default '2008082700',
      `resp_person` varchar(64) NOT NULL default 'resp.person.email',
      `primary_ns` varchar(64) NOT NULL default 'ns1.yourdns.here',
      `data_count` int(11) NOT NULL default '0',
      PRIMARY KEY  (`id`),
      KEY `host` (`host`),
      KEY `zone` (`zone`),
      KEY `type` (`type`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1
    That's about it. Now all you need to do is enter records into the table.

    Code:
    // for www.domain.com to resolve to 1.2.3.4
    insert into dns_records (zone, host, type, data, mx_priority) values ('domain.com', 'www', 'A', '1.2.3.4', null)
    
    // for domain.com to resolve to 1.2.3.4
    insert into dns_records (zone, host, type, data, mx_priority) values ('domain.com', '@', 'A', '1.2.3.4', null)
    
    // for www2.domain.com to alias to www.domain.com
    // note the trailing period in the data field
    insert into dns_records (zone, host, type, data, mx_priority) values ('domain.com', 'www2', 'CNAME', 'www.domain.com.', null)
    
    // for mail for domain.com to go to domain.com
    // note the trailing period in the data field
    insert into dns_records (zone, host, type, data, mx_priority) values ('domain.com', '@', 'MX', 'domain.com.', '0')
    I won't go into too much detail about DNS, unless you need help with it. Just remember that any records that have a name in the data field - MX, CNAME, etc - need a trailing period. Also, MX records MUST have a name in the data field, not an IP, otherwise it won't work properly.

    Let me know if you need any more assistance.

  6. #6
    Join Date
    Mar 2007
    Location
    Darwin, Australia
    Beans
    23
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Bind+DLZ+MySQL Hardy

    lol at googling my own thread; Thanks for your reply mate - I will have a crack at it again tonight and see how i go!

    Cheers,

    Kahn

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •