ติดตั้ง DNS Server บน Centos 6

ในการแปลง IP Address ในระบบอินเตอร์เนตให้ไปเป็นชื่อโดเมนเนม หรือกลับกันจากโดเมนเนมไปเป็น IP Address นั้น ต้องใช้ DNS Server ใน Centos 6 หรือ linux ใช้ ฺ Bind ในการทำ DNS สำหรับบทความนี้เป็นการ config Bind ใน Cenos 6

ข้อมูลที่ใช้
IP นอก 185.220.68.196
IP ภายใน 192.168.2.102
Domain pi3.club

เริ่มแรกให้ลง Bind ก่อน
# yum install bind bind-libs bind-utils
แก้ไขไฟ์ /etc/resolv.conf
#vi /etc/resolv.conf
เพิ่ม nameserver ที่เป็น ip address ของเครื่องเซอร์เวอร์
nameserver 192.168.2.102 (IP Address ของเครื่องที่จะทำ DNS )
แก้ไขไฟล์ /etc/named.conf
#vi /etc/named.conf

// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
// listen-on port 53 { 127.0.0.1; 185.220.68.196; };
// listen-on-v6 port 53 { ::1; };
directory “/var/named”;
dump-file “/var/named/data/cache_dump.db”;
statistics-file “/var/named/data/named_stats.txt”;
memstatistics-file “/var/named/data/named_mem_stats.txt”;
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* Path to ISC DLV key */
bindkeys-file “/etc/named.iscdlv.key”;
managed-keys-directory “/var/named/dynamic”;
};
logging {
channel default_debug {
file “data/named.run”;
severity dynamic;
};
};
zone “.” IN {
type hint;
file “named.ca”;
};
zone “pi3.club” IN {
type master;
file “/var/named/pi3.club.zone”;
allow-update { none; };
};

include “/etc/named.rfc1912.zones”;
include “/etc/named.root.key”;

สร้างโซนไฟล์ใหม่ขึ้นมา
#vi /var/named/pi3.club.zone
เขียนไฟล์ตามนี้

$TTL 86400
@ IN SOA pi3.club. root.pi3.club. (
103
1H
1M
1W
1D )

@ IN NS ns1.pi3.club.
@ IN A 185.220.68.196
ns1 IN A 185.220.68.196
@ IN MX 10 mail.pi3.club.
mail IN A 185.220.68.196
www IN A 185.220.68.196
ftp.pi3.club. IN A 185.220.68.196

ให้ระบบทำงานทุกครั้งที่เปิดเครื่อง
# chkconfig named on
สั่งให้ named ทำงาน
# service named start
ตรวจสอบการทำงานของโซนที่เราใส่ไปตะกี่ว่าถูกต้องหรือไม่ ซึ่งถ้าเราป้อนชื่อโดเมนลงไป ระบบจะคืนค่าไอพีของโดเมนนั้นกลับมาให้เรา

# nslookup pi3.club
จะแสดง IP ของ server ให้ดู

จากนั้นรออัพเดท dns อย่าลืมเอา Dns ที่เราสร้างไปใส่ใน nameserver ของผู้ให้บรการจดโดเมนที่เราใช้อยู่ ของผมจะเป็น ns1.pi3.club และ ns2.pi3.club เนื่องจากต้องกรอก 2 อัน จึงต้องเพิ่ม ns2

Div24Hr.COM
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.