close

OS : Centos 5.5

----------------------------------
setp 01. (1)安裝 DNS (Bind 9)  的相關套件
----------------------------------
   .bind ..............................DNS 主程式
 .bind-chroot ..................將 bind 主程式關在家理
 .bind-utils ......................用戶搜詢主機名稱的相關指令
 .system-config-bind ..........為圖形化的DNS 設定工具
 .caching-nameserver ............提供設定Caching-Only DNS 所需的設定

# yum -y install bind bind-chroot bind-utlis system-config-bind caching-nameserver  

----------------------------------
setp 02. 設定 /var/named/chroot
----------------------------------
# cd /var/named/chroot/etc  <-- 切換至 etc 目錄下
# cp named.caching-nameserver.conf   named.conf  <-- 覆製 named.caching-nameserver.conf,另存成 named.conf
# ll  <-- 觀察 named.conf 檔案權限, 此時應為 root root
# chown root:named named.conf  <-- 變更 named.conf 檔案權限
# ll  <-- 觀察 named.conf 檔案權限, 此時應變稱為 root named
# service named restart  <-- 修改後需重新啟動,讓設定值生效。會先關畢,然後再啟動

# vi /var/named/chroot/etc/named.conf  <-- 修改 named.conf
將 listen-on port 53 { 127.0.0.1; };
修改成 listen-on port 53 { any; };  <-- 將127.0.0.1 改為 any,表示監聽所有 53 port 介面

將 allow-query     { localhost; };
修改成 allow-query     { any; };  <-- 將 localhost 改為 any,表示允許外部來此台 dns 查詢

# service named restart  <-- 修改後需重新啟動,讓設定值生效。會先關畢,然後再啟動

----------------------------------
setp 03. 新增 網域名稱
----------------------------------
◎假設網域名稱 ne160.kirnel.com
 .新增加網域名稱 hello.ne160.kirnel.com
 .新增加網域名稱 kitty.ne160.kirnel.com

      ne160.kirnel.com ( 140.137.217.160 )
          /       \
         /         \
        hello        kitty
     ne160.kirnel.com  ne160.kirnel.com
     140.137.217.160  140.137.217.160
         |        |
┌-------- ┼- Apache -┼-------┐
| /opt/hello <┘        └> /opt/kitty |
└-------------------------┘

# vi /var/named/chroot/etc/named.conf  <-- 修改 etc 目錄下的 named.conf 檔
將 match-client     { localhost; };
修改成 match-client     { any; };

將 match-destinations     { localhost; };
修改成 match-destinations     { any; };

# vi /var/named/chroot/etc/named.rfc1912.zones  <-- 修改 named.rfc1912.zones 檔案
增加以下:
zone "ne160.kirnel.com" IN {
        type master;
        file "ne160.zone";
        allow-update { none; };
};

# cd /var/named/chroot/var/named
# ll  <-- 觀察是否有 ne160.zone
# cp localhost.zone ne160.zone  <-- 覆製 localhost.zone,另存成 ne160.zone
# ll  <-- 觀察 ne160.zone 檔案權限,此時應為 root root
# chown root:named ne160.zone  <-- 變更 ne160.zone 檔案權限
# ll  <-- 觀察 ne160.zone 檔案權限,此時應變稱為 root named

# vi /var/named/chroot/var/named/ne160.zone  <-- 修改 ne160.zone,新增加 hello 及 kitty 網域
增加以下:
hello  IN A  140.137.217.160
kitty  IN A  140.137.217.160

# service named restart  <-- 修改完後,重新啟動 named。會先關畢,然後再啟動

# chkconfig named on  <-- 設定每次開機就啟動 named 功能

----------------------------------
setp 04. 測試
----------------------------------
# vi /etc/resolv.conf  <-- 設定 DNS
增加以下:
nameserver 168.95.1.1

# dig hello.ne160.kirnel.com @localhost  <-- 使用本端機的 DNS,來查 hello.ne160.kirnel.com
# dig hello.ne160.kirnel.com @168.95.1.1  <-- 使用中華電信的 DNS,來查 hello.ne160.kirnel.com
# dig kitty.ne160.kirnel.com @localhost  <-- 使用本端機的 DNS,來查 kitty.ne160.kirnel.com
# dig kitty.ne160.kirnel.com @168.95.1.1  <-- 使用中華電信的 DNS,來查 kitty.ne160.kirnel.com

**測試在 Windows 下使用 ping 指令
 .ping hello.ne160.kirnel.com
 .ping kitty.ne160.kirnel.com



**建立 hello 及 kitty 網站目錄
# cd /opt  <-- 切換至 /opt 目錄下,觀查有無 hello 及 kitty 目錄
# mkdir /opt/hello  <-- 在 /opt 目錄下建立 hello 網站目錄
# mkdir /opt/kitty  <-- 在 /opt 目錄下建立 kitty 的網站目錄

**建立網站內容文字
# echo "This is hello web." > /opt/hello/index.html  <-- 在 hello 目錄下建立 index.html 檔案
# echo "This is kitty web." > /opt/kitty/index.html  <-- 在 kitty 目錄下建立 index.html 檔案

**建立虛擬網站
# service httpd restart  <-- 重新啟動。會先關畢,然後再啟動
# cd /etc/httpd/conf  <-- 切換至 conf 目錄下
# vi httpd.conf
增加以下:
NameVirtualHost 140.137.217.160:80

<VirtualHost 140.137.217.160:80>
    ServerAdmin hello@ne160.kirnel.com
    DocumentRoot /opt/hello
    ServerName hello.ne160.kirnel.com
    ErrorLog /var/log/hello-error_log
    CustomLog /var/log/hello-access_log common
</VirtualHost>

<VirtualHost 140.137.217.160:80>
    ServerAdmin kitty@ne160.kirnel.com
    DocumentRoot /opt/kitty
    ServerName kitty.ne160.kirnel.com
    ErrorLog /var/log/kitty-error_log
    CustomLog /var/log/kitty-access_log common
</VirtualHost>

# service httpd restart  <-- 修改後,重新啟動。會先關畢,然後再啟動

**測試網站是否正確建立完成
 .在 Windows 下開啟瀏覽器,在網址列內輸入 http://hello.ne160.kirnel.com
 .在 Windows 下開啟瀏覽器,在網址列內輸入 http://kitty.ne160.kirnel.com

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ........... 的頭像
    ...........

    ..........

    ........... 發表在 痞客邦 留言(0) 人氣()