ค้นหาเว็บไซต์

วิธีติดตั้งและกำหนดค่า 'PowerDNS' (พร้อม MariaDB) และ 'PowerAdmin' ใน RHEL/CentOS 7


PowerDNS เป็นเซิร์ฟเวอร์ DNS ที่ทำงานบนอนุพันธ์ของ Linux/Unix จำนวนมาก สามารถกำหนดค่าด้วยแบ็กเอนด์ที่แตกต่างกัน รวมถึงไฟล์โซนสไตล์ BIND ฐานข้อมูลเชิงสัมพันธ์ หรืออัลกอริธึมการปรับสมดุลโหลด/การเฟลโอเวอร์ นอกจากนี้ยังสามารถตั้งค่าเป็นตัวเรียกซ้ำ DNS ที่ทำงานเป็นกระบวนการแยกต่างหากบนเซิร์ฟเวอร์

เวอร์ชันล่าสุดของเซิร์ฟเวอร์ PowerDNS Authoritative คือ 3.4.4 แต่เวอร์ชันที่มีอยู่ในพื้นที่เก็บข้อมูล EPEL ในขณะนี้คือ 3.4.3 ฉันอยากจะแนะนำให้ติดตั้งอันหนึ่งสำหรับพื้นที่เก็บข้อมูล EPEL เนื่องจากเวอร์ชันนี้ได้รับการทดสอบใน CentOS และ Fedora ด้วยวิธีนี้คุณจะสามารถอัปเดต PowerDNS ได้อย่างง่ายดายในอนาคต

บทความนี้ตั้งใจจะแสดงวิธีการติดตั้งและตั้งค่าเซิร์ฟเวอร์หลัก PowerDNS ด้วยแบ็กเอนด์ MariaDB และ PowerAdmin ซึ่งเป็นเครื่องมือจัดการเว็บอินเตอร์เฟสที่เป็นมิตรสำหรับ พาวเวอร์ DNS

เพื่อวัตถุประสงค์ของบทความนี้ ฉันจะใช้เซิร์ฟเวอร์กับ:

Hostname: centos7.localhost 
IP Address 192.168.0.102

ขั้นตอนที่ 1: การติดตั้ง PowerDNS ด้วย MariaDB Backend

1. ขั้นแรก คุณต้องเปิดใช้งานพื้นที่เก็บข้อมูล EPEL สำหรับเซิร์ฟเวอร์ของคุณ เพียงใช้:

yum install epel-release.noarch 

2. ขั้นตอนต่อไปคือการติดตั้งเซิร์ฟเวอร์ MariaDB สามารถทำได้ง่ายๆ โดยใช้คำสั่งต่อไปนี้:

yum -y install mariadb-server mariadb

3. ต่อไป เราจะกำหนดค่า MySQL ให้เปิดใช้งานและเริ่มต้นเมื่อบูตระบบ:

systemctl enable mariadb.service
systemctl start mariadb.service

4. ขณะนี้บริการ MySQL กำลังทำงานอยู่ เราจะรักษาความปลอดภัยและตั้งค่ารหัสผ่านสำหรับ MariaDB โดยการเรียกใช้:

mysql_secure_installation
ปฏิบัติตามคำแนะนำ
/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  Press ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y     
New password:  ← Set New Password
Re-enter new password:  ← Repeat Above Password
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y ← Choose “y” to disable that user
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n ← Choose “n” for no
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y ← Choose “y” for yes
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y ← Choose “y” for yes
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

5. เมื่อกำหนดค่า MariaDB สำเร็จแล้ว เราจะดำเนินการติดตั้ง PowerDNS ต่อไปได้ เสร็จสิ้นอย่างง่ายดายด้วยการรัน:

yum -y install pdns pdns-backend-mysql

6. ไฟล์การกำหนดค่าสำหรับ PowerDNS อยู่ใน /etc/pdns/pdns แต่ก่อนที่จะแก้ไข เราจะตั้งค่าฐานข้อมูล MySQL สำหรับ บริการ PowerDNS ขั้นแรก เราจะเชื่อมต่อกับเซิร์ฟเวอร์ MySQL และจะสร้างฐานข้อมูลชื่อ powerdns:

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE powerdns;

7. ต่อไป เราจะสร้างผู้ใช้ฐานข้อมูลชื่อ powerdns:

MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'centos7.localdomain' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> FLUSH PRIVILEGES;

หมายเหตุ: แทนที่ “tecmint123 ” ด้วยรหัสผ่านจริงที่คุณต้องการใช้สำหรับการตั้งค่าของคุณ

8. เราดำเนินการต่อโดยการสร้างตารางฐานข้อมูลที่ใช้โดย PowerDNS ดำเนินการบล็อกเหล่านั้นทีละบล็อก:

MariaDB [(none)]> USE powerdns;
MariaDB [(none)]> 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)
);

MariaDB [(none)]> CREATE UNIQUE INDEX name_index ON domains(name);
MariaDB [(none)]> 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)
);

MariaDB [(none)]> CREATE INDEX rec_name_index ON records(name);
MariaDB [(none)]> CREATE INDEX nametype_index ON records(name,type);
MariaDB [(none)]> CREATE INDEX domain_id ON records(domain_id);

MariaDB [(none)]> CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

ตอนนี้คุณสามารถออกจากคอนโซล MySQL ได้โดยพิมพ์:

MariaDB [(none)]> quit;

9. ในที่สุด เราก็สามารถดำเนินการกำหนดค่า PowerDNS ของเราในลักษณะที่จะใช้ MySQL เป็นแบ็กเอนด์ได้ เพื่อจุดประสงค์ดังกล่าว ให้เปิดไฟล์การกำหนดค่า PowerDNS ซึ่งอยู่ที่:

vim /etc/pdns/pdns.conf 

ในไฟล์นั้นให้มองหาบรรทัดที่มีลักษณะดังนี้:

#################################
launch        Which backends to launch and order to query them in
#
launch=

หลังจากนั้นให้ใส่รหัสต่อไปนี้:

launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=user-pass
gmysql-dbname=powerdns

เปลี่ยน “บัตรผ่านผู้ใช้ ” ด้วยรหัสผ่านจริงที่คุณตั้งไว้ก่อนหน้านี้ นี่คือลักษณะการกำหนดค่าของฉัน:

บันทึกการเปลี่ยนแปลงของคุณและออกจาก

10. ตอนนี้เราจะเริ่มต้นและเพิ่ม PowerDNS ในรายการบริการโดยเริ่มตั้งแต่การบูตระบบ:

systemctl enable pdns.service 
systemctl start pdns.service 

ณ จุดนี้เซิร์ฟเวอร์ PowerDNS ของคุณเริ่มทำงานแล้ว สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ PowerDNS คุณสามารถดูคู่มือได้ที่ http://downloads.powerdns.com/documentation/html/index.html