Difference between revisions of "PowerDNS: Instalasi di Ubuntu"

From OnnoWiki
Jump to navigation Jump to search
Line 2: Line 2:
 
Scenario:
 
Scenario:
  
Operating system: Ubuntu 14.04 LTS server
+
Operating system: Ubuntu 14.04 LTS server
IP Address: 192.168.1.250/24
+
IP Address: 192.168.1.250/24
Hostname: server.unixmen.local
+
Hostname: server.unixmen.local
Update your system:
+
Update your system:
  
 
First of all, update your system:
 
First of all, update your system:
  
sudo apt-get update && sudo apt-get upgrade -y
+
sudo apt-get update && sudo apt-get upgrade -y
 +
 
 
Setup MySQL:
 
Setup MySQL:
  
sudo apt-get install mysql-server mysql-client
+
sudo apt-get install mysql-server mysql-client
 +
 
 
During installation you’ll be asked to set MySQL root user password. While it’s not mandatory, It is highly recommended.
 
During installation you’ll be asked to set MySQL root user password. While it’s not mandatory, It is highly recommended.
  
sk@server: ~_001
+
sk@server: ~_001
  
 
Re-enter the password.
 
Re-enter the password.
  
sk@server: ~_002
+
sk@server: ~_002
  
 
Now, edit /etc/mysql/my.cnf to make MySQL to listen all interfaces.
 
Now, edit /etc/mysql/my.cnf to make MySQL to listen all interfaces.
  
sudo vi /etc/mysql/my.cnf
+
sudo vi /etc/mysql/my.cnf
 +
 
 
Find the following line, and comment it out.
 
Find the following line, and comment it out.
  
[...]
+
[...]
#bind-address          = 127.0.0.1
+
#bind-address          = 127.0.0.1
[...]
+
[...]
 +
 
 
Save and close the file. Restart MySQL service.
 
Save and close the file. Restart MySQL service.
  
sudo service mysql restart
+
sudo service mysql restart
 +
 
 
We completed the installation now. Next, we will Install PowerDNS.
 
We completed the installation now. Next, we will Install PowerDNS.
  
Line 38: Line 43:
 
Run the following command to install PowerDNS.
 
Run the following command to install PowerDNS.
  
sudo apt-get install pdns-server pdns-backend-mysql
+
sudo apt-get install pdns-server pdns-backend-mysql
 +
 
 
Press ‘Yes’ to configure database for pdns-backend-mysql with dbconfig-common.
 
Press ‘Yes’ to configure database for pdns-backend-mysql with dbconfig-common.
  
sk@server: ~_003
+
sk@server: ~_003
  
 
Provide MySQL root user password:
 
Provide MySQL root user password:
  
sk@server: ~_004
+
sk@server: ~_004
  
 
Then, provide a password for pdns-backend-mysql to register with the database serve.
 
Then, provide a password for pdns-backend-mysql to register with the database serve.
  
sk@server: ~_005
+
sk@server: ~_005
  
 
Re-enter password:
 
Re-enter password:
  
sk@server: ~_006
+
sk@server: ~_006
  
 
PowerDNS has been installed now.
 
PowerDNS has been installed now.
Line 62: Line 68:
 
Enter to MySQL prompt using command:
 
Enter to MySQL prompt using command:
  
sudo mysql -u root -p
+
sudo mysql -u root -p
 +
 
 
Create database, namely ‘powerdns’. You can define your own.
 
Create database, namely ‘powerdns’. You can define your own.
  
CREATE DATABASE powerdns;
+
CREATE DATABASE powerdns;
Create database user, namely ‘poweruser’.
+
Create database user, namely ‘poweruser’.
 +
 
 +
GRANT ALL ON powerdns.* TO 'poweruser '@'localhost' IDENTIFIED BY 'ubuntu';
  
GRANT ALL ON powerdns.* TO 'poweruser '@'localhost' IDENTIFIED BY 'ubuntu';
 
 
Here,
 
Here,
  
Line 81: Line 89:
 
Enter the following command to update the user settings.
 
Enter the following command to update the user settings.
  
FLUSH PRIVILEGES;
+
FLUSH PRIVILEGES;
 +
 
 
Now, use the powerdns database with command:
 
Now, use the powerdns database with command:
  
USE powerdns;
+
USE powerdns;
 +
 
 
Create the necessary tables and records.
 
Create the necessary tables and records.
  
 
First, let us create domains table:
 
First, let us create domains table:
  
CREATE TABLE domains (
+
CREATE TABLE domains (
id INT auto_increment,
+
id INT auto_increment,
name VARCHAR(255) NOT NULL,
+
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
+
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
+
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
+
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
+
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
+
account VARCHAR(40) DEFAULT NULL,
primary key (id)
+
primary key (id)
);
+
);
Create Unique Index for domains table:
+
Create Unique Index for domains table:
 +
 +
CREATE UNIQUE INDEX name_index ON domains(name);
  
CREATE UNIQUE INDEX name_index ON domains(name);
 
 
Create records table:
 
Create records table:
  
CREATE TABLE records (
+
CREATE TABLE records (
id INT auto_increment,
+
id INT auto_increment,
domain_id INT DEFAULT NULL,
+
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
+
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
+
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
+
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
+
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
+
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
+
change_date INT DEFAULT NULL,
primary key(id)
+
primary key(id)
);
+
);
 +
 
 
Create the following indexes for records table:
 
Create the following indexes for records table:
  
CREATE INDEX rec_name_index ON records(name);
+
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
+
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
+
CREATE INDEX domain_id ON records(domain_id);
Create the supermasters table:
+
Create the supermasters table:
 +
 +
CREATE TABLE supermasters (
 +
ip VARCHAR(25) NOT NULL,
 +
nameserver VARCHAR(255) NOT NULL,
 +
account VARCHAR(40) DEFAULT NULL
 +
);
  
CREATE TABLE supermasters (
 
ip VARCHAR(25) NOT NULL,
 
nameserver VARCHAR(255) NOT NULL,
 
account VARCHAR(40) DEFAULT NULL
 
);
 
 
Finally, exit from MySQL prompt using command:
 
Finally, exit from MySQL prompt using command:
  
quit;
+
quit;
 +
 
 
Configure PowerDNS
 
Configure PowerDNS
 
Now, we should configure PowerDNS to use MySQL as backend to store Zone files and records.
 
Now, we should configure PowerDNS to use MySQL as backend to store Zone files and records.
Line 135: Line 149:
 
Remove the existing PowerDNS configuration files.
 
Remove the existing PowerDNS configuration files.
  
sudo rm /etc/powerdns/pdns.d/*.*
+
sudo rm /etc/powerdns/pdns.d/*.*
 +
 
 
Then, create file /etc/powerdns/pdns.d/pdns.local.gmysql.conf file;
 
Then, create file /etc/powerdns/pdns.d/pdns.local.gmysql.conf file;
  
sudo vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf
+
sudo vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf
 +
 
 
Add the following lines. Set the correct database name and database user which we created earlier.
 
Add the following lines. Set the correct database name and database user which we created earlier.
  
# MySQL Configuration
+
# MySQL Configuration
#
+
#
# Launch gmysql backend
+
# Launch gmysql backend
launch=gmysql
+
launch=gmysql
 +
 +
# gmysql parameters
 +
gmysql-host=localhost
 +
gmysql-dbname=powerdns
 +
gmysql-user=poweruser
 +
gmysql-password=ubuntu
  
# gmysql parameters
 
gmysql-host=localhost
 
gmysql-dbname=powerdns
 
gmysql-user=poweruser
 
gmysql-password=ubuntu
 
 
Finally restart powerdns service.
 
Finally restart powerdns service.
  
sudo service pdns restart
+
sudo service pdns restart
 +
 
 
Test PowerDNS
 
Test PowerDNS
 +
 
First, edit /ect/resolv.conf file,
 
First, edit /ect/resolv.conf file,
  
sudo vi /etc/resolv.conf
+
sudo vi /etc/resolv.conf
 +
 
 
Set the name server IP address:
 
Set the name server IP address:
  
auto lo
+
auto lo
iface lo inet loopback
+
iface lo inet loopback
 +
 +
# The primary network interface
 +
auto eth0
 +
iface eth0 inet static
 +
address 192.168.1.250
 +
netmask 255.255.255.0
 +
network 192.168.1.0
 +
broadcast 192.168.1.255
 +
gateway 192.168.1.1
 +
dns-nameservers 192.168.1.250
 +
dns-search home
  
# The primary network interface
 
auto eth0
 
iface eth0 inet static
 
address 192.168.1.250
 
netmask 255.255.255.0
 
network 192.168.1.0
 
broadcast 192.168.1.255
 
gateway 192.168.1.1
 
dns-nameservers 192.168.1.250
 
dns-search home
 
 
We completed all installation and configuration parts. Now, we will check whether PowerDNS is really working or not.
 
We completed all installation and configuration parts. Now, we will check whether PowerDNS is really working or not.
  
 
First check if PowerDNS is listening:
 
First check if PowerDNS is listening:
  
sudo netstat -tap | grep pdns
+
sudo netstat -tap | grep pdns
 +
 
 
Sample output:
 
Sample output:
  
tcp        0      0 *:domain                *:*                    LISTEN      1549/pdns_server-in
+
tcp        0      0 *:domain                *:*                    LISTEN      1549/pdns_server-in
 +
 
 
Now, enter the following command to check PowerDNS is working:
 
Now, enter the following command to check PowerDNS is working:
  
sudo dig @127.0.0.1
+
sudo dig @127.0.0.1
 +
 
 
Or,
 
Or,
  
sudo dig @localhost
+
sudo dig @localhost
 +
 
 
Sample output:
 
Sample output:
  
; <<>> DiG 9.9.5-3-Ubuntu <<>> @127.0.0.1
+
; <<>> DiG 9.9.5-3-Ubuntu <<>> @127.0.0.1
; (1 server found)
+
; (1 server found)
;; global options: +cmd
+
;; global options: +cmd
;; Got answer:
+
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65075
+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65075
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
+
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
+
;; WARNING: recursion requested but not available
 +
 +
;; OPT PSEUDOSECTION:
 +
; EDNS: version: 0, flags:; udp: 2800
 +
;; QUESTION SECTION:
 +
;.                IN    NS
 +
 +
;; Query time: 4 msec
 +
;; SERVER: 127.0.0.1#53(127.0.0.1)
 +
;; WHEN: Mon Mar 30 14:38:58 IST 2015
 +
;; MSG SIZE  rcvd: 29
  
;; OPT PSEUDOSECTION:
+
Or,
; EDNS: version: 0, flags:; udp: 2800
 
;; QUESTION SECTION:
 
;.                IN    NS
 
  
;; Query time: 4 msec
+
sudo dig @192.168.1.250
;; SERVER: 127.0.0.1#53(127.0.0.1)
 
;; WHEN: Mon Mar 30 14:38:58 IST 2015
 
;; MSG SIZE  rcvd: 29
 
Or,
 
  
sudo dig @192.168.1.250
 
 
Where, 192.168.1.250 is my PowerDNS server’s IP address.
 
Where, 192.168.1.250 is my PowerDNS server’s IP address.
  
 
Sample output:
 
Sample output:
  
; <<>> DiG 9.9.5-3-Ubuntu <<>> @192.168.1.250
+
; <<>> DiG 9.9.5-3-Ubuntu <<>> @192.168.1.250
; (1 server found)
+
; (1 server found)
;; global options: +cmd
+
;; global options: +cmd
;; Got answer:
+
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39576
+
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39576
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
+
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
+
;; WARNING: recursion requested but not available
 
+
;; OPT PSEUDOSECTION:
+
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 2800
+
; EDNS: version: 0, flags:; udp: 2800
;; QUESTION SECTION:
+
;; QUESTION SECTION:
;.                IN    NS
+
;.                IN    NS
 +
 +
;; Query time: 0 msec
 +
;; SERVER: 192.168.1.250#53(192.168.1.250)
 +
;; WHEN: Mon Mar 30 14:39:49 IST 2015
 +
;; MSG SIZE  rcvd: 29
  
;; Query time: 0 msec
 
;; SERVER: 192.168.1.250#53(192.168.1.250)
 
;; WHEN: Mon Mar 30 14:39:49 IST 2015
 
;; MSG SIZE  rcvd: 29
 
 
That’s it. PowerDNS is ready to use.
 
That’s it. PowerDNS is ready to use.
  

Revision as of 14:00, 27 May 2015

Install PowerDNS On Ubuntu Scenario:

Operating system: Ubuntu 14.04 LTS server
IP Address: 192.168.1.250/24
Hostname: server.unixmen.local
Update your system:

First of all, update your system:

sudo apt-get update && sudo apt-get upgrade -y

Setup MySQL:

sudo apt-get install mysql-server mysql-client

During installation you’ll be asked to set MySQL root user password. While it’s not mandatory, It is highly recommended.

sk@server: ~_001

Re-enter the password.

sk@server: ~_002

Now, edit /etc/mysql/my.cnf to make MySQL to listen all interfaces.

sudo vi /etc/mysql/my.cnf

Find the following line, and comment it out.

[...]
#bind-address           = 127.0.0.1
[...]

Save and close the file. Restart MySQL service.

sudo service mysql restart

We completed the installation now. Next, we will Install PowerDNS.

Install PowerDNS:

Run the following command to install PowerDNS.

sudo apt-get install pdns-server pdns-backend-mysql

Press ‘Yes’ to configure database for pdns-backend-mysql with dbconfig-common.

sk@server: ~_003

Provide MySQL root user password:

sk@server: ~_004

Then, provide a password for pdns-backend-mysql to register with the database serve.

sk@server: ~_005

Re-enter password:

sk@server: ~_006

PowerDNS has been installed now.

Create PowerDNS Database and User in MySQL The next step is we should now create the necessary database, user account, tables, and records etc., for the PowerDNS.

Enter to MySQL prompt using command:

sudo mysql -u root -p

Create database, namely ‘powerdns’. You can define your own.

CREATE DATABASE powerdns;
Create database user, namely ‘poweruser’.
GRANT ALL ON powerdns.* TO 'poweruser '@'localhost' IDENTIFIED BY 'ubuntu';

Here,

powerdns – is the database;

poweruser – is the database user,

ubuntu – is the password for the ‘poweruser’ user.

I recommend you to use any strong password to tighten the security.

Enter the following command to update the user settings.

FLUSH PRIVILEGES;

Now, use the powerdns database with command:

USE powerdns;

Create the necessary tables and records.

First, let us create domains table:

CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
Create Unique Index for domains table:

CREATE UNIQUE INDEX name_index ON domains(name);

Create records table:

CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);

Create the following indexes for records table:

CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
Create the supermasters table:

CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

Finally, exit from MySQL prompt using command:

quit;

Configure PowerDNS Now, we should configure PowerDNS to use MySQL as backend to store Zone files and records.

Remove the existing PowerDNS configuration files.

sudo rm /etc/powerdns/pdns.d/*.*

Then, create file /etc/powerdns/pdns.d/pdns.local.gmysql.conf file;

sudo vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf

Add the following lines. Set the correct database name and database user which we created earlier.

# MySQL Configuration
#
# Launch gmysql backend
launch=gmysql

# gmysql parameters
gmysql-host=localhost
gmysql-dbname=powerdns
gmysql-user=poweruser
gmysql-password=ubuntu

Finally restart powerdns service.

sudo service pdns restart

Test PowerDNS

First, edit /ect/resolv.conf file,

sudo vi /etc/resolv.conf

Set the name server IP address:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.250
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.250
dns-search home

We completed all installation and configuration parts. Now, we will check whether PowerDNS is really working or not.

First check if PowerDNS is listening:

sudo netstat -tap | grep pdns

Sample output:

tcp        0      0 *:domain                *:*                     LISTEN      1549/pdns_server-in

Now, enter the following command to check PowerDNS is working:

sudo dig @127.0.0.1

Or,

sudo dig @localhost

Sample output:

; <<>> DiG 9.9.5-3-Ubuntu <<>> @127.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65075
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 2800
;; QUESTION SECTION:
;.                IN    NS

;; Query time: 4 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Mar 30 14:38:58 IST 2015
;; MSG SIZE  rcvd: 29

Or,

sudo dig @192.168.1.250

Where, 192.168.1.250 is my PowerDNS server’s IP address.

Sample output:

; <<>> DiG 9.9.5-3-Ubuntu <<>> @192.168.1.250
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39576
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 2800
;; QUESTION SECTION:
;.                IN    NS

;; Query time: 0 msec
;; SERVER: 192.168.1.250#53(192.168.1.250)
;; WHEN: Mon Mar 30 14:39:49 IST 2015
;; MSG SIZE  rcvd: 29

That’s it. PowerDNS is ready to use.

I have successfully installed and configured PowerDNS, now what? It is time to manage PowerDNS using Poweradmin administration tool.


Referensi