การจัดการบริการ
ตรวจสอบสถานะ CoreDNS:
systemctl status coredns
รีสตาร์ท CoreDNS:
systemctl restart coredns
โหลด CoreDNS ใหม่:
systemctl reload coredns
หยุด CoreDNS:
systemctl stop coredns
เริ่ม CoreDNS:
systemctl start coredns
ดูบันทึกของ CoreDNS:
journalctl -u coredns -f
การกำหนดค่า DNS
การกำหนดค่าหลักของ CoreDNS คือ:
/etc/coredns/Corefile
การกำหนดค่าเริ่มต้นจะส่งต่อคำสอบถาม DNS ไปที่:
1.1.1.1 8.8.8.8
กำหนดค่า Corefile ตามความต้องการเฉพาะและกรณีใช้งานของคุณ
หลังแก้ไข Corefile ให้รีสตาร์ต CoreDNS:
systemctl restart coredns
ปลายทาง DNS
- DNS:
53/tcpและ53/udp - สถานะสุขภาพ:
http://127.0.0.1:8080/health - พร้อมใช้งาน:
http://127.0.0.1:8181/ready - เมตริก:
http://127.0.0.1:9153/metrics
ไฟล์และไดเรกทอรีที่สำคัญ
- ไบนารี:
/usr/bin/coredns - Corefile:
/etc/coredns/Corefile - เซอร์วิส:
/etc/systemd/system/coredns.service - Sysusers:
/usr/lib/sysusers.d/coredns.conf - Tmpfiles:
/usr/lib/tmpfiles.d/coredns.conf - Logrotate:
/etc/logrotate.d/coredns - ไดเร็กทอรีข้อมูล:
/var/lib/coredns - ไฟล์ล็อก:
/var/log/coredns.log - ล็อกข้อผิดพลาด:
/var/log/coredns.err.log - การแทนที่ค่า resolver:
/etc/systemd/resolved.conf.d/99-coredns.conf
ทดสอบการแปลงชื่อ DNS
สอบถาม CoreDNS โดยตรง:
dig @127.0.0.1 example.com
หรือสอบถามโดยใช้ IP ของเซิร์ฟเวอร์:
dig @<SERVER-IP> example.com
The host's /etc/resolv.conf is configured to use:
nameserver 127.0.0.1
หมายเหตุ
- CoreDNS uses
systemd-resolvedการเปลี่ยนการกำหนดค่าเพื่อปล่อยพอร์ต 53 - The host resolver is pointed to
127.0.0.1. - คำสอบถาม DNS จะถูกส่งต่อไปยัง resolver ต้นทางที่กำหนดไว้
- CoreDNS runs under the dedicated
corednssystem user.