dns解析服务器搭建(单机)

2020-05-14 15:01:25   工作备份

 

  1. yum -y install bind-utils bind bind-devel bind-libs
  2. 配置文件
  3. vim /etc/named.conf
  4. ···
  5. options {
  6. listen-on port 53 { any; };
  7. listen-on-v6 port 53 { ::1; };
  8. directory "/var/named";
  9. dump-file "/var/named/data/cache_dump.db";
  10. statistics-file "/var/named/data/named_stats.txt";
  11. memstatistics-file "/var/named/data/named_mem_stats.txt";
  12. recursing-file "/var/named/data/named.recursing";
  13. secroots-file "/var/named/data/named.secroots";
  14. allow-query { any; };
  15. recursion yes;
  16. dnssec-enable yes;
  17. dnssec-validation yes;
  18. bindkeys-file "/etc/named.iscdlv.key";
  19. managed-keys-directory "/var/named/dynamic";
  20. pid-file "/run/named/named.pid";
  21. session-keyfile "/run/named/session.key";
  22. forwarders { 114.114.114.114; };#dns转发
  23. };
  24. logging {
  25. channel default_debug {
  26. file "data/named.run";
  27. severity dynamic;
  28. };
  29. };
  30. zone "." IN {
  31. type hint;
  32. file "named.ca";
  33. };
  34. include "/etc/named.rfc1912.zones";
  35. include "/etc/named.root.key";
  36. ···
  37. 追加域名解析入口配置
  38. vim /etc/named.rfc1912.zones
  39. 新增
  40. ···
  41. zone "a.com" IN { # 测试用的域是 a.com
  42. type master;
  43. file "a.com.zone"; # 配置文件为 a.com.zone,该文件目录为 /var/named/ 下
  44. };
  45. ···
  46. 新增解析文件
  47. /var/named/
  48. cp named.localhost a.com.zone
  49. chown named.named a.com.zone
  50. ···
  51. $TTL 1D
  52. @ IN SOA @ rname.invalid. (
  53. 0 ; serial
  54. 1D ; refresh
  55. 1H ; retry
  56. 1W ; expire
  57. 3H ) ; minimum
  58. NS @
  59. A 127.0.0.1
  60. AAAA ::1
  61. a IN A 47.111.97.147
  62. ···
  63. systemctl start named
  64. dig @127.0.0.1 a.com查看结果