• Ubuntu DNS Server 配置


    一、    DNS说明

            DNS使用端口号:53

               正解与反解说明:

                   正解:通过Domain(DNS下的hostname)应射IP;通过hostname去找IP

                   反解:通过IP反查hostname

               Zone(区域):一个正解或一个反解的设定就是一个zone

    二、    安装DNS的套件:bind9

             sudo apt-get install bind9

              查看安装后的相关目录文件:sudo dpkg – L bind9

                 查看端口是否已启动:netstat – tunlp | grep 53 

    三、    DNS设定:

             配置环境:DNS Server IP192.168.1.254 hostnamesamba.elantech.com

                DNS Server下的配置文件有如下:

                        /etc/bind/named.conf.options        //全局设置

                        /etc/bind/named.conf.default-zone    //添加或删除zone的配置

                        /etc/bind/db.127                   //本机反解

                        /etc/bind/db.local                  //本机正解

    四、    DNS Server 配置:

            配置步骤如下:

              

    1、修改全局选项   sudo vi /etc/bind/named.conf.options

                  转发的IP地址修改成广东电信的DNS IP

    forwarders {

                    202.96.128.143;

             };

     

               2、添加zone  sudo vi /etc/bind/named.conf.default-zone

                  添加2zone ,“db.elantech.com”用来正解、“db.192”是用来反解

                 

              zone "elantech.com"  {

                     type master;

                     file "/etc/bind/db.elantech.com";

    };

     

    zone "1.168.192.in-addr.arpa" {

                        type master;

                        file "/etc/bind/db.192";

    };

     

    3、设定DNS的正解:sudo cp /etc/bind/db.local /etc/bind/db.elantech.com

                      

     root@samba:/etc/bind# vi db.elantech.com

    ;

    ; BIND data file for local loopback interface

    ;

    $TTL    604800

    @       IN      SOA     elantech.com. root.elantech.com. (

                                  2         ; Serial

                             604800         ; Refresh

                              86400         ; Retry

                            2419200         ; Expire

                             604800 )       ; Negative Cache TTL

    ;

    @       IN      NS      elantech.com.

    @       IN      A       192.168.1.254

    samba   IN      A       192.168.1.254         

     

    4、设定DNS的反解:  sudo cp /etc/bind/db.127 /etc/bind/db.192

     

    root@samba:/etc/bind# vi db.192

    ;

    ; BIND reverse data file for local loopback interface

    ;

    $TTL    604800

    @       IN      SOA     elantech.com. root.elantech.com. (

                                  1         ; Serial

                             604800         ; Refresh

                              86400         ; Retry

                            2419200         ; Expire

                             604800 )       ; Negative Cache TTL

    ;

    @       IN      NS      elantech.com.

    1.0.0   IN      PTR     samba.elantech.com.

    254     IN      PTR   samba.elantech.com.

     

    5、启动bind服务: sudo /etc/inti.d/bind9 restart

     

    6、查看启动bind服务的日志: tail /var/log/syslog

     

    root@samba:/etc/bind# tail /var/log/syslog

    Aug  3 10:15:14 samba named[1228]: command channel listening on ::1#953

    Aug  3 10:15:14 samba named[1228]: zone 0.in-addr.arpa/IN: loaded serial 1

    Aug  3 10:15:14 samba named[1228]: zone 127.in-addr.arpa/IN: loaded serial 1

    Aug  3 10:15:14 samba named[1228]: zone 1.168.192.in-addr.arpa/IN: loaded serial 1

    Aug  3 10:15:14 samba named[1228]: zone 255.in-addr.arpa/IN: loaded serial 1

    Aug  3 10:15:14 samba named[1228]: zone elantech.com/IN: loaded serial 2

    Aug  3 10:15:14 samba named[1228]: zone localhost/IN: loaded serial 2

    Aug  3 10:15:14 samba named[1228]: managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found

    Aug  3 10:15:14 samba named[1228]: managed-keys-zone ./IN: loaded serial 0

    Aug  3 10:15:14 samba named[1228]: running

     

    7、在本机(192.168.1.254)上设置DNS sudo /etc/resolv.conf

                           添加一行, nameserver 192.168.1.254

    五、    测试DNS

    1、 DNS Server

           命令:host samba.elantech.com (正解)

                samba.elantech.com has address 192.168.1.254

           命令:host 192.168.1.254     (反解)

          254.1.168.192.in-addr.arpa domain name pointer samba.elantech.com.

    2、 在客户端

           命令: nslookup www.baidu.com

                     C:\Documents and Settings\Administrator>nslookup www.baidu.com

    Server:  samba.elantech.com

    Address:  192.168.1.254

     

    Non-authoritative answer:

    Name:    www.a.shifen.com

    Addresses:  220.181.112.143, 220.181.111.148

    Aliases:  www.baidu.com

    参考:

    http://wenku.baidu.com/view/7e97a35777232f60dccca101.html

    ——————
    无论在哪里做什么,只要坚持服务、创新、创造价值,其他的东西自然都会来的。
  • 相关阅读:
    Hibernate配置
    Log4j 局部笔记
    有关接口 笔记 懒人版
    JAVA面向对象编程这本书的摘录~!(2016-5-23)
    关于关闭数据流
    安卓桌面开发小应用
    ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)
    hdu 1573 A/B (扩展欧几里得)
    hdu 1788 Chinese remainder theorem again(最小公倍数)
    ACM hdu 1019 Least Common Multiple
  • 原文地址:https://www.cnblogs.com/pied/p/3010286.html
Copyright © 2020-2023  润新知