PowerDNS on SuSE Linux & SQL Server 2005 – Part 1
I have been working on a scenario for one of our services and that’s our DNS back-end. It has to achieve the following criteria.
- A Fast and Reliable DNS Service
- SQL Server Database Back-end for management. (as we already run MS SQL as standard)
- Linux Based DNS Server (better supported, free & reliable)
- VMware Virtual Server
So after a good look around we have decided on PowerDNS, SuSE Linux Enterprise 10.1 & MS SQL Server 2005 as the DBMS.
Now this is where the fun starts. I’m no Linux expert but I can find my way around pretty well. Let me tell you, getting this to work was not easy, 3 long days of head scratching, disparate documentation and perseverance. This is probably the only HOWTO there is on doing this.
Assumptions.
- You already have SQL 2005 Installed and available on the network.
- Your relativity competent in Windows / Linux administration.
- You understand DNS concepts.
Steps to install SuSE on VMware Workstation
- Create your virtual machine environment and start it up. In my case I have chosen VMware Workstation 5 with ESX Server 3 compatibility. 512MB of RAM and 4GB of disk space split into 2GB files.
- Install SuSE Linux by mounting the ISO image on the virtual machines CDROM drive. I have chosen just to install the base server system but included the C++ compilation tools for building software.
- Once SuSE is installed you need to install the VMware tools. Select this from the VM menu. Once installed run the command # /usr/bin/vmware-config-tools.pl this sets up the proper screen drivers and allows things like shared folders, copy & paste between virtual machine and the host.
Hit ctrl-backspace to restart the X windows system. You should now have a base Linux System running under VMware.
First let’s get all the files we need :-
PowerDNS v2.9.22 (Authoritative Name Server)
http://download.opensuse.org/repositories/server:/dns/openSUSE_10.3/i586/pdns-2.9.22-1.1.i586.rpm
PowerDNS v2.9.x OpenDBX Backend (PDNS Database access via OpenDBX)
http://download.opensuse.org/repositories/server:/dns/openSUSE_10.3/i586/pdns-snapshot-backend-opendbx-2.9.x.r1107-3.3.i586.rpm
OpenDBX Library (DBMS API)
http://linuxnetworks.de/opendbx/download/opendbx-1.2.3.tar.gz
FreeTDS Library (allows communication from Linux to various DBMS including SQL Server
ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
MySQL header libraries as it is a dependency for PDNS.
http://download.opensuse.org/repositories/server:/database/openSUSE_10.3/i586/libmysqlclient15-5.0.67-20.1.i586.rpm
Create a suitable directory on you Linux OS and copy the downloaded files to this directory. I have used /root/Documents/PDNS. The shared folders directory on the Linux guest is under /mnt/hgfs.
Once you have the files extract the tar’s for OpenDBX & FreeTDS.
Installing FreeTDS and Connecting to MS SQL Server
The first item we need to install is FreeTDS, basically TDS stands for Tabular Data Stream and is the protocol that MS SQL Server uses to communicate with it’s clients. You can read more about it @ http://www.freetds.org/
Open a terminal window up, change directory to where you extracted the FreeTDS software to.
Run the following commands to build and install it:-
$ ./configure
$ make
$ make install
Great, if you didn’t get any errors we can now configure the connection. Load up gedit and open /usr/local/etc/freetds.conf go the end of the file and add the following:-
# My connection to SQL Server 2005 on PC12SQL2005D_1
[MySQLServer2005]
host = pc21.outerin.uk-net
instance = SQL2005D_1
; port = 1433
tds version = 8.0
Subsitute the host, instance or port for that of your SQL Server Instance. If you use instance then the port is auto-detected. Save the file and quit.
NOTE : Make sue you can resolve the remote SQL server and you can get a response. If you can’t make sure
a) etc/hosts file has an entry
b) your DNS server is correct.
c) any firewalls allow the SQL traffic through.
Lets test the connection by running the command tsql.
Excellent we now have a connection to SQL Server.
Set up the PowerDNS Database on MS SQL Server.
Execute this script on SQL Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | USE [master] GO /****** Object: Database [PowerDNS] Script Date: 10/17/2008 12:15:22 ******/ CREATE DATABASE [PowerDNS] ON PRIMARY ( NAME = N'PowerDNS_Data', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAPowerDNS_Data.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'PowerDNS_Log', FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAPowerDNS_Log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) GO EXEC dbo.SP_DBCMPTLEVEL @dbname = N'PowerDNS', @new_cmptlevel = 90 GO IF ( 1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled') ) BEGIN EXEC [PowerDNS].[dbo].[SP_FULLTEXT_DATABASE] @ACTION = 'disable' END GO ALTER DATABASE [PowerDNS] SET ANSI_NULL_DEFAULT OFF GO ALTER DATABASE [PowerDNS] SET ANSI_NULLS OFF GO ALTER DATABASE [PowerDNS] SET ANSI_PADDING OFF GO ALTER DATABASE [PowerDNS] SET ANSI_WARNINGS OFF GO ALTER DATABASE [PowerDNS] SET ARITHABORT OFF GO ALTER DATABASE [PowerDNS] SET AUTO_CLOSE OFF GO ALTER DATABASE [PowerDNS] SET AUTO_CREATE_STATISTICS ON GO ALTER DATABASE [PowerDNS] SET AUTO_SHRINK OFF GO ALTER DATABASE [PowerDNS] SET AUTO_UPDATE_STATISTICS ON GO ALTER DATABASE [PowerDNS] SET CURSOR_CLOSE_ON_COMMIT OFF GO ALTER DATABASE [PowerDNS] SET CURSOR_DEFAULT GLOBAL GO ALTER DATABASE [PowerDNS] SET CONCAT_NULL_YIELDS_NULL OFF GO ALTER DATABASE [PowerDNS] SET NUMERIC_ROUNDABORT OFF GO ALTER DATABASE [PowerDNS] SET QUOTED_IDENTIFIER OFF GO ALTER DATABASE [PowerDNS] SET RECURSIVE_TRIGGERS OFF GO ALTER DATABASE [PowerDNS] SET ENABLE_BROKER GO ALTER DATABASE [PowerDNS] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO ALTER DATABASE [PowerDNS] SET DATE_CORRELATION_OPTIMIZATION OFF GO ALTER DATABASE [PowerDNS] SET TRUSTWORTHY OFF GO ALTER DATABASE [PowerDNS] SET ALLOW_SNAPSHOT_ISOLATION OFF GO ALTER DATABASE [PowerDNS] SET PARAMETERIZATION SIMPLE GO ALTER DATABASE [PowerDNS] SET READ_WRITE GO ALTER DATABASE [PowerDNS] SET RECOVERY FULL GO ALTER DATABASE [PowerDNS] SET MULTI_USER GO ALTER DATABASE [PowerDNS] SET PAGE_VERIFY CHECKSUM GO ALTER DATABASE [PowerDNS] SET DB_CHAINING OFF GO USE [PowerDNS] GO /****** Object: Table [dbo].[domains] Script Date: 10/17/2008 12:21:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[domains] ( [id] [INT] IDENTITY(1, 1) NOT NULL, [name] [VARCHAR](255) NOT NULL, [type] [VARCHAR](6) NOT NULL, [master] [VARCHAR](40) NOT NULL DEFAULT ( '' ), [account] [VARCHAR](40) NOT NULL DEFAULT ( '' ), [notified_serial] [INT] NULL, [last_check] [INT] NULL, [status] [CHAR](1) NOT NULL DEFAULT ( 'A' ), CONSTRAINT [pk_domains_id] PRIMARY KEY CLUSTERED ( [id] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY], CONSTRAINT [unq_domains_name] UNIQUE NONCLUSTERED ( [name] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[records] Script Date: 10/17/2008 12:21:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[records] ( [id] [INT] IDENTITY(1, 1) NOT NULL, [domain_id] [INT] NOT NULL, [name] [VARCHAR](255) NOT NULL, [type] [VARCHAR](6) NOT NULL, [ttl] [INT] NULL, [prio] [INT] NULL, [content] [VARCHAR](255) NOT NULL, [change_date] [INT] NULL, CONSTRAINT [pk_records_id] PRIMARY KEY CLUSTERED ( [id] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[supermasters] Script Date: 10/17/2008 12:21:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[supermasters] ( [ip] [VARCHAR](40) NOT NULL, [nameserver] [VARCHAR](255) NOT NULL, [account] [VARCHAR](40) NOT NULL DEFAULT ( '' ) ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[records] WITH CHECK ADD CONSTRAINT [fk_records_domainid] FOREIGN KEY ( [domain_id] ) REFERENCES [dbo].[domains] ( [id] ) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[records] CHECK CONSTRAINT [fk_records_domainid] USE [master] GO CREATE LOGIN [powerdns] WITH PASSWORD= N'secret', DEFAULT_DATABASE= [PowerDNS], DEFAULT_LANGUAGE= [us_english], CHECK_EXPIRATION= OFF, CHECK_POLICY= OFF GO ALTER LOGIN [powerdns] ENABLE GO USE [PowerDNS] GO CREATE USER [powerdns] FOR LOGIN [powerdns] GO GRANT DELETE ON [dbo].[domains] TO [powerdns] GO GRANT INSERT ON [dbo].[domains] TO [powerdns] GO GRANT REFERENCES ON [dbo].[domains] TO [powerdns] GO GRANT SELECT ON [dbo].[domains] TO [powerdns] GO GRANT UPDATE ON [dbo].[domains] TO [powerdns] GO GRANT DELETE ON [dbo].[records] TO [powerdns] GO GRANT INSERT ON [dbo].[records] TO [powerdns] GO GRANT REFERENCES ON [dbo].[records] TO [powerdns] GO GRANT SELECT ON [dbo].[records] TO [powerdns] GO GRANT UPDATE ON [dbo].[records] TO [powerdns] GO GRANT SELECT ON [dbo].[supermasters] TO [powerdns] GO |
Build and Install the OpenDBX Library
We need to build the OpenDBX library backend for SQL Server 2005 (for other backends please refer to http://www.linuxnetworks.de/doc/index.php/OpenDBX for more info)
Change to the OpenDBX directory where you extracted the files and issue the command
$ ./configure –with-backends=”mssql”
$ make
$ make install
Once completed we need to install PowerDNS and the PowerDNS OpenDBX backend.
Install the MySQL header libraries as it is a dependency for PDNS.
Hit Install to install the package
Install the pdns-2.9.21-17.4.i586.rpm package
Hit Install to install the package.
Install the OpenDBX backend
This package will not install. Instead open it in “File Roller” and extract the contents to /usr/lib/pdns this is where they are looked for.
Testing the PowerDNS installation
Once installed test the PowerDNS installation by issuing the command:-
$ /etc/init.d/pdns monitor
you should see an error message as below.

This means we have successfully installed the PowerDNS server and we now need to configure it. Open the file /etc/pdns/pdns.conf in gedit
Find the following section
#################################
# launch Which backends to launch and order to query them in
#
# launch=
and change to:-
#################################
# launch Which backends to launch and order to query them in
#
launch=opendbx
opendbx-backend=mssql
opendbx-host-read=MySQLServer2005
opendbx-host-write=MySQLServer2005
opendbx-database=PowerDNS
opendbx-username=powerdns
opendbx-password=secret
opendbx-sql-transactbegin=BEGIN TRANSACTION
NOTE: make sure there are no spaces next to the = sign. It won’t work
Try the command again:-
$ /etc/init.d/pdns monitor
Success we have a Database driven DNS system!!
Testing the DNS
Enter the command
$ host www.example.com 127.0.0.1
The address will not be resolved as we haven’t any data in the database yet. Run the following SQL on the database (you can change the IP addresses and names to suit you own).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | USE [PowerDNS] GO INSERT INTO domains (name, type) VALUES ('example.com', 'NATIVE'); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','localhost postmaster@example.com 1','SOA',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','ns1.outerin.net','NS',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','ns2.outerin.net','NS',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'www.example.com','192.168.1.100','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'mail.example.com','192.168.1.252','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'localhost.example.com','127.0.0.1','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','mail.example.com','MX',120,25); |
Now try the command again. Your should see a returned record, success; we are getting result and our setup is working.
In the next part I’ll be increasing the security and getting the DNS to start up automatically. I’ll also be looking at the master/salve configuration and seeing how it ties together.
Thanks to Norbert @ Linux Networks for getting me over the last hurdle. Check out the following website for further information.
http://www.linuxnetworks.de
http://www.powerdns.com
http://www.freetds.org
http://software.opensuse.org
http://download.opensuse.org/repositories
Regards
Tobi




Should this work the same on OpenSuse 11?
You only posted this a short while ago….yet none of the links you posted to the software seem to work and I have been unable to find rpm packages for the latest version.
I would like to setup this same configuration…just not sure what pieces I need anymore as it seems that PowerDNS now includes OpenDBX. Also…it seems that FreeTDS is included in OpenDBX now?
Very confused…
Thanks,
Jim
Hi Jim,
Sorry for the long delay, I just have had no time to update the Blog. I have updated the links for 10.3 as they had been removed from the Suse Repository. This should all work fine on 11.0 however you could download updated packages for Suse from :-
http://download.opensuse.org/repositories/server:/database/openSUSE_11.0/i586
http://download.opensuse.org/repositories/server:/dns/openSUSE_11.0/i586/
Regards
Tobi
After reading the article, I just feel that I need more info. Can you suggest some more resources ?
Hi Pirsey,
There not much esle other than what’s available on the post, one of the reasons I did it. If there is anything specific I can help with, I will do my best.
Regards
Tobi.
I really liked this post. Can I copy it to my site? Thank you in advance.
Sure Andrew, do with as you need. Just provide a link back to the original just incase I update it.
Tobi.
Hi
I did what the article said, but the command “tsql -S localhost -U sa” resulted in the error:
Msg 20009, Level 9, State -1, ServerOpenClient, Line -1
Unable to Connect:Adaptive Server is unavailable or does not exist
there was a problem connecting to the server
the entry of freetds.conf is:
[localhost]
host = localhost
port = 1433
tdsVersion = 8.0
I run the tsql command on suse10 installed on vmware on windows XP
I have an entry of local host in \etc\hosts file
please help me to fix the problem, as u mentioned in u’r article, there is no other article about connecting to SQL Server 2005 from a vmwared suse 10.
Hi,
TDS is the protocol that SQL Server uses. The host=localhost needs to be pointed to the name of the server/computer that SQL Server is listening on. Also SQL will only default to port 1433 if it is NOT a named instance. For example if you have a computer called MYPC and SQL server as the default instance you can just specify the name. If you have an instance call SQL2005D_1 then you will need to also use the instance setting as detailed in the HowTo.
Regards
Toby
I really appreciate for your reply.
would you please help me in these questions also?
my computer name is “green” and the instance of my SQL server is MYSQL.
i changed the content of the freetds.conf file to:
[localhost] //does the server name have to be written in braces?
host = green
instance = MYSQL
;port = 1433 //is ignored
tds Version = 8.0
the command “tsql -S localhost -U sa” is used to check the connection, but this time after password line, the error “There was a problem connecting to the server” appeared. now what should i do?
I installed the DNS server on my windows server 2003. is it necessary to run a DNS server on linux also?
I knew from HOWTO that installing freetds is required for connecting to SQL server. is it also necessary to install other packages you listed in HOWTO like libmysqlclient15?
my /mnt/hgfs directory is empty. does it have to contain any file?
regards
rose
Hi Rose,
The set up I describe is MS SQL Server on windows providing the data store for the PDNS Authroative DNS Server running on Linux. Make sure that your windows server (green) can be pinged from the Linux server and also you can telnet on port 1434 to green to check that the port for The SQL Browser is listening this is used to resolve the port that the instance of MSSQL is listening on. Also try telneting to the port that the MS SQL Server is listening on. In short make sure that everything is reachable before testing using tsql.
regards
Tobi
As for me, everything is fully satisfied.
Thanks for time and effort you put in to this. Very helpful!