歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 使用bind配置DNS實驗

使用bind配置DNS實驗

日期:2017/3/1 16:36:27   编辑:關於Linux
使用bind配置DNS實驗 一、實驗環境: Red Hat Enterprise Linux Server release 5.6 主機名 www.2cto.com IP 系統版本 Host role hotel01 192.168.2.111 OEL5.6 server hotel02 192.168.2.112 OEL5.6 client hotel03 192.168.2.113 OEL5.6 client ….. www.2cto.com 配置說明:NDS服務器放在了hotel01(master)節點上,對hotel01、hotel02、hotel03節點的主機名進行解析。 二、安裝配置DNS 1. 安裝bind、caching-nameserver軟件包 --因使用的是未注冊的OEL版本,所以yum不能在線安裝bind軟件 --安裝下面bind包,如果缺少可以在安裝盤上查找並安裝 [root@hotel01 ~]# rpm -qa|grep bind bind-utils-9.3.6-16.P1.el5 ypbind-1.19-12.el5 bind-chroot-9.3.6-16.P1.el5 bind-9.3.6-16.P1.el5 bind-libs-9.3.6-16.P1.el5 bind-libbind-devel-9.3.6-16.P1.el5 bind-devel-9.3.6-16.P1.el5 bind-libs-9.3.6-16.P1.el5 [root@hotel01 ~]# rpm -qa|grep caching-nameserver caching-nameserver-9.3.6-16.P1.el5 2. 修改bind配置文件 BIND的配置文件name.conf還有區域文件都在/var/named/chroot/目錄下 配置文件named.conf在/var/named/chroot/etc/下,區域配置文件在/var/named/chroot/var/named/下 1) 修改配置文件named.conf [root@hotel01 ~]# cd /var/named/chroot/etc [root@hotel01 etc]# cp -p named.caching-nameserver.conf named.conf [root@hotel01 etc]# vi named.conf options { listen-on port 53 { any; }; --把127.0.0.1改成any 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"; // Those options should be used carefully because they disable port // randomization // query-source port 53; // query-source-v6 port 53; allow-query { any; }; allow-query-cache { any; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; view localhost_resolver { match-clients { any; }; --把localhost改成any match-destinations { any; }; --把localhost改成any recursion yes; include "/etc/named.rfc1912.zones"; }; 2) 修改配置文件named.rfc1912.zones,在文件中添加以下內容 [root@hotel01 etc]# pwd /var/named/chroot/etc [root@hotel01 etc]# vi named.rfc1912.zones zone "licz.com" IN { //這是自己設置的域名 type master; file "licz.com.zone"; allow-update { none; }; }; zone "2.168.192.in-addr.arpa" IN { //這是反向配置文件 type master; file "2.168.192.in-addr.zone"; allow-update { none; }; }; 3) 創建leonarding.com.zone和2.168.192.in-addr.zon 區域文件 [root@hotel01 etc]# cd /var/named [root@hotel01 named]# cp -p localdomain.zone chroot/var/named/licz.com.zone [root@hotel01 named]# cp -p named.local chroot/var/named/2.168.192.zone --修改leonarding.com.zone和2.168.192.in-addr.zon 區域文件 [root@hotel01 named]# cd /var/named/chroot/var/named [root@hotel01 named]# vi licz.com.zone $TTL 86400 @ IN SOA localhost root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS localhost //添加下面的正向文件內容 hotel01 IN A 192.168.2.111 hotel02 IN A 192.168.2.112 hotel03 IN A 192.168.2.113 [root@hotel01 named]# vi 2.168.192.in-addr.zone $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS localhost. //添加下面的反向向文件內容 111 IN PTR hotel01.licz.com 112 IN PTR hotel02.licz.com 113 IN PTR hotel03.licz.com 4) 修改各節點/etc/resolv.conf文件 [root@hotel01 named]# vi /etc/resolv.conf nameserver 192.168.2.111 [root@hotel02 named]# vi /etc/resolv.conf nameserver 192.168.2.111 [root@hotel03 named]# vi /etc/resolv.conf nameserver 192.168.2.111 3. 驗證測試 [root@hotel01 etc]# nslookup > hotel01.licz.com Server: 192.168.2.111 Address: 192.168.2.111#53 Name: hotel01.licz.com Address: 192.168.2.111 > hotel02.licz.com Server: 192.168.2.111 Address: 192.168.2.111#53 Name: hotel02.licz.com Address: 192.168.2.112 > hotel03.licz.com Server: 192.168.2.111 Address: 192.168.2.111#53 Name: hotel03.licz.com Address: 192.168.2.113 [root@hotel01 named]# ping hotel03.licz.com PING hotel03.licz.com (192.168.2.113) 56(84) bytes of data. 64 bytes from hotel03 (192.168.2.113): icmp_seq=1 ttl=64 time=10.8 ms 64 bytes from hotel03 (192.168.2.113): icmp_seq=2 ttl=64 time=0.360 ms 64 bytes from hotel03 (192.168.2.113): icmp_seq=3 ttl=64 time=0.332 ms 64 bytes from hotel03 (192.168.2.113): icmp_seq=4 ttl=64 time=0.299 ms 64 bytes from hotel03 (192.168.2.113): icmp_seq=5 ttl=64 time=0.306 ms
Copyright © Linux教程網 All Rights Reserved