Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1824942
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: LINUX

2016-03-10 11:17:46

为了适应人类对文字的印象比数字高
1./etc/hosts
2.分布式,阶层式管理架构:DNS系统

DNS采用树型结构框架
完整主机名FQDN
一般顶级域名:.com,.org,.gov等
地区顶级层域名:.uk,.jp,.cn等
每上一层的DNS服务器所记录的信息,其实只有其下一层的主机名而已.
主机名追踪:dig +trace
[t@bjb0541 ~]$ cat /etc/services |grep domain
domain          53/tcp                          # name-domain server
domain          53/udp

DNS标记
    SOA:开始验证
    NS:域名服务器
    A:地址
    PTR:反解指向

客户端相关配置文件:
    /etc/hosts本地解析
    /etc/resolv.conf域名解析
    /etc/nsswitch.conf决定以上两个配置的解析顺序

解析常用命令:host,nslookup,dig,whois

服务器架设:
[root@192-168-174-42 ~]# yum install bind bind-chroot
配置文件:
    /etc/named.conf主配置文件
    /var/named数据库
    /etc/sysconfig/named额外参数
    /var/run/named PID文件


点击(此处)折叠或打开

  1. [root@192-168-174-42 ~]# cat /etc/named.conf
  2. //
  3. // named.conf
  4. //
  5. // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
  6. // server as a caching only nameserver (as a localhost DNS resolver only).
  7. //
  8. // See /usr/share/doc/bind*/sample/ for example named configuration files.
  9. //

  10. options {
  11. // listen-on port 53 { 127.0.0.1; };
  12.         listen-on port 53 { any; };//修改监听所有接口
  13.         //listen-on-v6 port 53 { ::1; };
  14.         directory "/var/named";//数据库目录
  15.         dump-file "/var/named/data/cache_dump.db";//一些统计信息
  16.         statistics-file "/var/named/data/named_stats.txt";
  17.         memstatistics-file "/var/named/data/named_mem_stats.txt";
  18.         //allow-query { localhost; };
  19.         allow-query { any; };

  20.         /*
  21.          - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
  22.          - If you are building a RECURSIVE (caching) DNS server, you need to enable
  23.            recursion.
  24.          - If your recursive DNS server has a public IP address, you MUST enable access
  25.            control to limit queries to your legitimate users. Failing to do so will
  26.            cause your server to become part of large scale DNS amplification
  27.            attacks. Implementing BCP38 within your network would greatly
  28.            reduce such attack surface
  29.         */
  30.         recursion yes;//将自己视为客户端
  31.                 allow-recursion { localhost; 192.168.184.0/24; };
  32.         forward only;
  33.         forwarders {
  34.                 223.5.5.5;
  35.                 114.114.114.114;
  36.         };
  37.         dnssec-enable no;
  38.         dnssec-validation no;

  39.         /* Path to ISC DLV key */
  40.         bindkeys-file "/etc/named.iscdlv.key";

  41.         managed-keys-directory "/var/named/dynamic";

  42.         pid-file "/run/named/named.pid";
  43.         session-keyfile "/run/named/session.key";
  44. };

  45. logging {
  46.         channel default_debug {
  47.                 file "data/named.run";
  48.                 severity dynamic;
  49.         };
  50. };

  51. zone "." IN {
  52.         type hint;
  53.         file "named.ca";
  54. };
  55. zone "skyovirt.com" IN {
  56.         type master;
  57.         file "named.skyovirt.com";
  58. };
  59. zone "192.168.184.in-addr.arpa" IN {
  60.         type master;
  61.         file "named.192.168.184";
  62. };

  63. include "/etc/named.rfc1912.zones";//默认读取
  64. include "/etc/named.root.key"


点击(此处)折叠或打开

  1. [root@192-168-174-42 ~]# cat /var/named/named.skyovirt.com
  2. $TTL 600
  3. $ORIGIN skyovirt.com.
  4. @ IN SOA skyovirt.com. master.skyovirt.com. (
  5.                                         0 ; serial
  6.                                         3H ; refresh
  7.                                         15M ; retry
  8.                                         1W ; expire
  9.                                         1D ) ; minimum
  10.                                 IN NS skyovirt.com.
  11. skyovirt.com. IN A 192.168.184.11
  12. master.skyovirt.com. IN A 192.168.184.11
  13. ovirthost18.skyovirt.com. IN A 192.168.184.18
  14. ovirthost17.skyovirt.com. IN A 192.168.184.17
  15. ovirthost15.skyovirt.com. IN A 192.168.184.15
  16. ovirthost14.skyovirt.com. IN A 192.168.184.14
  17. ovirthost13.skyovirt.com. IN A 192.168.184.13
  18. ovirt.skyovirt.com. IN A 192.168.184.10
  19. dns.skyovirt.com. IN CNAME master.skyovirt.com.
  20. [root@192-168-174-42 ~]#

点击(此处)折叠或打开

  1. [root@192-168-174-42 ~]# cat /var/named/named.192.168.184
  2. $TTL 600
  3. @ IN SOA skyovirt.com. master.skyovirt.com. (
  4.                                         0 ; serial
  5.                                         1D ; refresh
  6.                                         1H ; retry
  7.                                         1W ; expire
  8.                                         3H ) ; minimum
  9. @ IN NS master.skyovirt.com.
  10. 11 IN PTR master.skyovirt.com.
  11. 18 IN PTR ovirthost18.skyovirt.com.
  12. 10 IN PTR ovirt.skyovirt.




重启服务.

点击(此处)折叠或打开

  1. [root@192-168-174-42 ~]# service named restart
  2. Redirecting to /bin/systemctl restart named.service
  3. [root@192-168-174-42 ~]# netstat -lntp |grep named
  4. tcp 0 0 192.168.184.11:53 0.0.0.0:* LISTEN 10210/named
  5. tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 10210/named
  6. tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 10210/named
  7. tcp6 0 0 ::1:53 :::* LISTEN 10210/named
  8. tcp6 0 0 ::1:953 :::* LISTEN 10210/named
  9. [root@192-168-174-42 ~]#
访问外网与自定义域名都OK

点击(此处)折叠或打开

  1. [root@192-168-174-42 ~]# dig ovirt.skyovirt.com

  2. ; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.2 <<>> ovirt.skyovirt.com
  3. ;; global options: +cmd
  4. ;; Got answer:
  5. ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30879
  6. ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

  7. ;; OPT PSEUDOSECTION:
  8. ; EDNS: version: 0, flags:; udp: 4096
  9. ;; QUESTION SECTION:
  10. ;ovirt.skyovirt.com. IN A

  11. ;; ANSWER SECTION:
  12. ovirt.skyovirt.com. 600 IN A 192.168.184.10

  13. ;; AUTHORITY SECTION:
  14. skyovirt.com. 600 IN NS skyovirt.com.

  15. ;; ADDITIONAL SECTION:
  16. skyovirt.com. 600 IN A 192.168.184.11

  17. ;; Query time: 0 msec
  18. ;; SERVER: 127.0.0.1#53(127.0.0.1)
  19. ;; WHEN: Thu Mar 10 17:05:16 CST 2016
  20. ;; MSG SIZE rcvd: 93

  21. [root@192-168-174-42 ~]# dig www.sky-mobi.com

  22. ; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.2 <<>> www.sky-mobi.com
  23. ;; global options: +cmd
  24. ;; Got answer:
  25. ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62581
  26. ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

  27. ;; OPT PSEUDOSECTION:
  28. ; EDNS: version: 0, flags:; udp: 4096
  29. ;; QUESTION SECTION:
  30. ;www.sky-mobi.com. IN A

  31. ;; ANSWER SECTION:
  32. www.sky-mobi.com. 200 IN A 111.1.17.157

  33. ;; Query time: 27 msec
  34. ;; SERVER: 127.0.0.1#53(127.0.0.1)
  35. ;; WHEN: Thu Mar 10 17:05:27 CST 2016
  36. ;; MSG SIZE rcvd: 61



阅读(1471) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~