DNS 介紹

Reviews
Shared by: vixycn
Stats
views:
23
rating:
not rated
reviews:
0
posted:
10/22/2009
language:
CHINESE_TRADITIONAL
pages:
0
Agenda Mail Server •DNS •Mail •Proxy DNS Server 3 1 Web Server 2 4 5 Proxy Server DNS Server •什麼是 DNS •DNS 的架構 •DNS 的運作原理 •DNS 安裝 •DNS 服務檢測 什麼是DNS ? •DNS (Domain Name Service) - 網域名稱服務的縮寫,其主要目地是在 解決機器的網域名稱(Domain name) 與 IP address 的對應問題。 提供 telnet、WWW browser、 ftp 等常用工具的基本服務。 什麼是 DNS (cont.) •什麼是 IP Address ? - 在網際網路(internet)上,自己桌上的機器要連上遠端的某一機 器,首先必需要知道遠端機器的 IP,IP 的格式是 xx.xx.xx.xx (如 163.15.40.202),其中xx範圍為0 ~ 255。IP Address 依前面4個bit 又分class A,class B,class C ,class D,class E 等五大類, 其中 class A 範圍 0~127.xx.xx.xx class B 範圍 128~191.xx.xx.xx class C 範192~223.xx.xx.xx class D 範圍 224~239 class E 範圍 240~255。 - IP 是電腦的網路地址。 什麼是 DNS (cont.) •什麼是“網域名稱” ? - 對於使用電腦的人來說, IP的位址不適合記憶與管 理. 因此有 Domain 的出現, 其格式亦為 xx.xx.xx.xx (如 www.tf.edu.tw, www.ee.tf.edu.tw),這樣的表示 方式較適合人來使用,以較有意義的英文字如 tf.edu.tw 來代替 IP,這一串英文字即為網域名稱。 什麼是 DNS (cont.) •DNS 提供的服務 - 領域名稱(Domain name)與位址(IP 的轉換 address)相互之間 •DNS 的兩大功能 - FORWARD DOMAIN(正解):DOMAIN NAME a IP ADDRESS - REVERSE DOMAIN(反解):IP ADDRESS a DOMAIN NAME DNS 的架構 - Domain DNS 的架構 (cont.) • DNS 以反轉樹狀為結構,為一全球性的分散式資料庫,以 “.”為樹根,各節點也以“.”作分隔,例如 www. tf.edu.tw 便是一個典型的網域名稱,右邊節點 “tw” 為樹狀結構的最上層,而左邊節點“www”則在樹狀結構 的最下層,每部機器對DNS系統上來說,其網域名稱均是 唯一的,不能同時有兩個相同的名稱。 • 由於 Internet 是起源美國,因此美國在名稱上面不須另 外加國家代碼,一般國家在網路上均需使用兩個字的國家 代碼,例如 ch 代表中國大陸,tw 代表臺灣,jp 代表日 本,若沒有寫,就是指美國了。 DNS 的第一層依照網路使用單位的特 性,大致分類成下列: •edu:教育及學術單位 •mil:軍事單位 •gov:政府機構 •com:商業機構 •org:法人機構 •net:網路機構 •國家代號:如 tw 為臺灣 Delegation (授權) •剛才提到每個domain都可因實際需求再細 分成許多sub domain。 •上層的domain可以將其分出的某個sub domain的domain name與IP mapping •交由另一部機器管理,這個動作我們稱之 為delegation(授權)。 Forward / Reverse domain name <-> IP mapping 其實應該看成兩個 •domain name -> IP,稱之為forward mapping。 在這個命名空間中就是先分成前面提到的那些top domain,再細分sub domain,再細分...。 比如說www.tf.edu.tw->163.15.40.203 代表在負責 tf.edu.tw 這個 domain 的機器上,可以查到其mapping table上有一筆記錄是 www->163.15.40.203。 Forward / Reverse •IP -> domain name 稱為reverse mapping。 在這個命名空間中,所有的IP組成一個叫作arpa.in-addr 的top domain,然後再依IP層層細分...。比如說 163.15.40.203 -> www.tf.edu.tw代表在負責 40.15.163.in-addr.arpa (注意是反過來寫,因為top domain要在最後面)這個sub domain的機器上,可以查到 其mapping table上有一筆記錄是 203 -> www.tf.edu.tw Name Server •負責記錄forward/reverse mapping的機器 會執行一個叫name server的軟體,透過這 個軟體回應來自其它機器對domain name或 IP的查詢。 DNS伺服器的分類 •DNS伺服器可分為三種,分別為 - 主要名稱伺服器 (Primary/master Server) - 次要名稱伺服器 (Secondary/slave Server) - 快取名稱伺服器 (Cache only Server) 主要名稱伺服器 (Primary/master Server) •主要名稱伺服器由它所在的主機上的檔案中取得 管理地帶的資料。如果您的學校擁有自己的網域 (Domain),則必須建立自己的DNS系統,來回答網 路上對您學校中,所有與網際網路有關的電腦名 稱與IP地址的轉換服務。 次要名稱伺服器 (Secondary/slave Server) • 次要名稱伺服器是由其他管理這個地帶的名稱伺 服器中取得地帶的資料。為了網路穩定度的考 慮,通常你需要一部次要名稱伺服器,以備不時 之需。 快取名稱伺服器 (Cache Only Server) •每個DNS都會將查詢過的 Domain Name 給 cache 起來,所以每個DNS都快取名稱伺服器的功能。硬 碟中沒有該 Domain 的 database 檔案。 DNS查詢方式 •相當於是DNS server的client端,通常是以函式 庫的方式被放在整套作業系統中,各類的應用程 式經由呼叫這個resolver函式庫可以很容易地向 DNS server進行查詢,得到所要的資料。 •forward domain(正解): 英文的 domain name  數字的IP Address。 •reverse domain(反查): 數字的 IP Address  英文的 domain name。 DNS 的運作原理 • DNS分為Client和Server,Client扮演發問的角色,也就 是問Server 一個Domain Name,而Server必須要回答此 Domain Name的真正IP地址。而當地的DNS先會查自己的資 料庫。如果自己的資料庫沒有,則會往該DNS上所設的的 DNS尋問,依此得到答案之後,將收到的答案存起來,並 回達客戶。 • 真正DNS的運作:有兩種詢問方法,Recursive和 Iterative兩種。前面是由DNS代理去問,問的方法是用 Iterative方式,後者是由本機直接做Iterative式的詢 問。 Recursive(遞迴式) DNS 用戶端向 DNS Server 的查詢模式 - 這種方式是將要查詢的封包送出去問,就 等待正確名稱的正確回應,這種方式只處 理回應回來的封包是否是正確回應或是說 是找不到該名稱的錯誤訊息。問的方式是 用Iterative的方式。 Iterative(交談式) DNS Server 間的查詢模式 - 由Client端或是DNS Server上所發出去問,這種方式送 封包出去問,所回應回來的資料不一定是最後正確的名 稱位置,但也不是如上所說的回應回來是錯誤訊息,也 許是另外一台DNS的位址(當該台DNS沒有答案時,會傳 回一台 “權威授權者” DNS的位址)。再由Client或 DNS自己向“ 權威授權者” DNS詢問。 一般說來,name resolver對local DNS server都是 recursive query,而DNS server之間的 query多是 iterative。大部份的DNS server都可以接受recursive 和iterative兩種query方式,但是考量負載問題,root name server只接受iterative query。 DNS運作步驟 1. 客戶端向伺服器提出查詢項目﹔ 2. 當被詢問到有關本域名之內的主機名稱的時候,DNS伺服 器會直接做出回答﹔ 3. 如果所查詢的主機名稱屬於其它域名的話,會檢查快取記 憶體(Cache),看看有沒有相關資料﹔ 4. 如果沒有發現,則會轉向root伺服器查詢﹔ 5. 然後root伺服器會將該域名之下一層授權 (authoritative)伺服器的位址告知(可能會超過一台)﹔ 6. 本地伺服器然後會向其中的一台伺服器查詢,並將這些伺 服器名單存到記憶體中,以備將來之需(省卻再向root查 詢的步驟)﹔ DNS運作步驟(cont.) 7. 遠方伺服器回應查詢﹔ 8. 若該回應並非最後一層的答案,則繼續往下一層 查詢, 直到獲得客戶端所查詢的結果為止﹔ 9. 將查詢結果回應給客戶端,並同時將結果儲存一 個備份 在自己的快取記憶裡面﹔ 10.如果在存放時間尚未過時之前再接到相同的查詢, 則以 存放於快取記憶裡面的資料來做回應。 • 從這個過程我們可以看出,沒有任何一台 DNS主機會包含所有域名的DNS資料,資料 都是分散在全部的DNS伺服器中,而NIC (Network Information Center) 只需知 道各DNS伺服器位址就可以了。 運作實例 DNS 安裝 • Bind 簡介 • 安裝平台-Unix system -將source code解壓縮後並進入該目錄底下 -執行Bind的組態設定 -編譯相關Bind檔案 -將Bind安裝置系統中 • 安裝範例 [root@linux root]# [root@linux root]# [root@linux root]# ……………… [root@linux root]# ……………… [root@linux root]# tar –zxvf bind-9.2.1.tar.gz cd bind-9.2.1 ./configure make make install DNS 相關的檔案目錄 • /etc/resolv.conf: 此檔案用以控制resolver的行為。 • /etc/namedb/named.conf: 此檔案為DNS的啟動設定檔, 是啟動DNS的源頭,最重要的檔案。 • /etc/namedb/named.root: 此檔案為全球性DNS的源頭。 • /etc/namedb/xx: xx為一目錄,任意名稱均可如為s,其 內容包含正解及反查的資料,如ccnet.hosts(正解), ccnet.rev(反查)。 • /etc/namedb: DNS的相關檔案及database均存放於此目錄 下。 DNS系統相關檔案的設定 •/etc/resolv.conf 之設定 domain dns.tf.edu.tw nameserver 163.15.40.202 •/etc/namedb/named.conf 之設定 •/etc/named/s/host-ringline 之設定 •/etc/named/s/rev-172.16.6 之設定 named.conf ………. zone "ringline.com.tw" { type master; file "s/host-ringline.com.tw"; }; zone “6.16.172.in-addr.arpa" { type master; file "s/rev-172.16.6"; }; s/host-ringline.com.tw • 下面的例子是 ringline.com.tw 領域的 SOA 記錄: @ IN SOA coco.ringline.com.tw. root.coco.ringline.com.tw.( 2004120201 ;serial 43200 ;refresh twice a day 3600 ;retry every hour 3600000 ;expire after 1000 hours 2419200 ;default ttl ls one month ) 安裝實例 • coco# cd /etc/namedb • coco# ls PROTO.localhost.rev make-localhost named.conf named.root • coco# sh make-localhost (產生 localhost.rev 檔案 ) • coco# ls PROTO.localhost.rev make-localhost named.root localhost.rev named.conf • vi named.conf zone "ringline.com.tw" { type master; file "s/host-ringline.com.tw"; }; zone “6.16.172.in-addr.arpa" { type master; file "s/rev-172.16.6"; }; •mkdir /etc/namedb/s •chown bind:bind /etc/namedb/s •chmod 750 /etc/namedb/s •vi s/host-ringline.com.tw •vi s/rev-172.16.6 •執行 dns service - named •check log - /var/log/message nslookup •DNS 測試 nslookup >server ip_address >snort.ringline.com.tw >172.16.6.100 DNS LAB • vi /etc/namedb/named.conf …….. zone "ringline.com.tw" { type master; file "host-ringline.com.tw"; }; > more host-ringline.com.tw $TTL 3600 @ IN SOA dns.ringline.com.tw. root.dns.ringline.com.tw. ( 2004120911;Serial 3600 ; Refresh 900 ; Retry 3600000 ; Expire 3600 ) ; Minimum dns.ringline.com.tw. 140.130.42.252 dns.tn.ringline.com.tw. A 140.130.201.252 172.16.6.15 172.16.6.11 IN NS dns IN A tn IN NS dns.tn IN www IN A oo IN A Mail Server •Mail system 的架構與運作原理 •WebMail 安裝 •Mail 測試 Mail System 的架構 Mail System 的架構 •User Agent (UA) •Deliver Agent (DA) •Transport Agent (TA) •SMTP - Simple Mail Transfer Protocol •POP - Post Office Protocol •IMAP - Internet Message Access Protocol User Agent (UA) •使用者所使用的讀信, 寫信程式,在 unix 環境中 最陽春的 mail, 其他在 unix 的 UA 還有 pine, elm, mutt 等等, 在 Windows 環境下的 Netscape 和 Microsoft 的 InternetMail 也都 算是 UA的一種. UA負責接收使用者的命令, 提供方便的讀/寫信件 的環境, 但並不負責實際傳遞信件的工作 Deliver Agent (DA) •TA 在收到一封信件後, 首先便是判斷這封 信件的目的地是不是自己, 如果不是當然 繼續轉送的動作, 如果目的地是自己 時, TA 便會把這封信件交由 DA 來處 理, DA 會負責真正地將信件傳給目的地主 機上的收信人. Transport Agent (TA) • 真正負責在 Internet 中轉送信件的程式, 最有名的就是 Sendmail 這個程式了, TA 在收到 UA 傳來的信件後, 會 根據信件的目的地作一些位址判別的動作, 然後將信件轉 送往目的地. • 有時候信件並不會一次就送往目的地去, 而是先轉到其它 主機的 TA, 再轉送到目的地去. 比如說要去的目的地主 機暫時故障, 或是目的地主機無法直接收到外來的 mail. 因此 TA 除了接受 UA 傳來的信件外, 也要接收其它 TA 傳來的信件, 並幫忙把這封信件轉送到目的地主機, 這個 動作我們稱之為 relay. TA 運作說明 Server A user1@serverA Mail to user1@serverB Server B SMTP •Internet (TCP/IP)上郵件傳遞的標準 •SMTP定義Internet上EMail交換的方式 •ESMTP=Extended SMTP,是SMTP的延伸大部 分EMail Server支援此一協定 •SMTP是連線導向(Connection Oriented)的 通訊協定 •sendmail是Unix中Default 的SMTP Server 程式 •SMTP use TCP port 25 UA, DA, TA 運作說明 SMTP 寄信 > telnet localhost 25 Trying 127.0.0.1... Connected to localhost.ncyu.edu.tw. Escape character is '^]'. 220 ltflow.ncyu.edu.tw ESMTP Sendmail 8.11.6/8.11.6; Thu, 9 Dec 2004 00:38:06 +0 800 (CST) HELO tn 250 ltflow.ncyu.edu.tw Hello localhost.ncyu.edu.tw [127.0.0.1], pleased to meet you MAIL from: 250 2.1.0 ... Sender ok RCPT to: 250 2.1.5 ... Recipient ok DATA 354 Enter mail, end with "." on a line by itself mail test from 140.130.201.252 port 25 . 250 2.0.0 iB8GcZD99072 Message accepted for delivery quit 221 2.0.0 ltflow.ncyu.edu.tw closing connection Connection closed by foreign host. Return-Path: Received: from mailgate.tn.ringline.com.tw (root@mailgate.tn.ringline.com.tw [172.16.6.200]) by tn.ringline.com.tw (8.12.11/8.12.11) with ESMTP id iB8Gt36p056318 for ; Thu, 9 Dec 2004 00:55:03 +0800 (CST) (envelope-from aa@bb.cc) Received: from ltflow.ncyu.edu.tw (201252.N.ncyu.edu.tw [140.130.201.252] (may be forged)) by mailgate.tn.ringline.com.tw with ESMTP id iB8Gsxv5018617 for ; Thu, 9 Dec 2004 00:54:59 +0800 (CST) (envelope-from aa@bb.cc) Received: from tn (localhost.ncyu.edu.tw [127.0.0.1]) by ltflow.ncyu.edu.tw (8.11.6/8.11.6) with SMTP id iB8GujD00858 for ; Thu, 9 Dec 2004 00:57:14 +0800 (CST) (envelope-from aa@bb.cc) Date: Thu, 9 Dec 2004 00:57:14 +0800 (CST) From: aa@bb.cc Message-Id: <200412081657.iB8GujD00858@ltflow.ncyu.edu.tw> To: undisclosed-recipients:; X-MAIL: mailgate.tn.ringline.com.tw iB8Gsxv5018617 X-yoursite-MailScanner-Information: Please contact the ISP for more information X-yoursite-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-MailScanner-From: aa@bb.cc X-UIDL: h)U"!)j##!T)g"!Kio"! POP3 •POP提供終端使用者(POP Client)自 EMail(POP) Server端取信的機制 •POP不負責將郵件傳給其他使用者或系統 •POP3是最新版的POP協定。By Default, Unix POP Service is Disabled。 •RedHat Linux中,POP在imap套件中。POP Service is Disabled By Default •POP3 use TCP port 110 IMAP •imap是一種自EMail Server中存取信件的協定 •imap是一種以伺服器為基礎的讀信工具 •Microsoft OutLook Express支援imap協定 (Client)。IMAP Service is Disabled by Default •IMAP2、IMAP4 use TCP port 143 Openwebmail 安裝 • 相關套件 - perl-CGI , perl-Compress-Zlib , - perl-Text-Iconv ,perl-suidperl - optional perl-CGI-SpeedyCGI • Pre-requisites – perl , httpd , sendmail • http://host+domain name/cgi-bin/openwebmail/openwebmail.pl Please execute '/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init' on server first! Linux command •rpm - i , v , h , e ,U - q , a ,c ,l rpm –ivh openwebmail-2.41-1.i386.rpm •yum [options] [command] [package ...] - option y - command install , upgrade , list - package file_name.rpm Openwebmail 初始化 • [root@nat openwebmail]# ./openwebmail-tool.pl --init Please change './etc/dbm.conf' from dbm_ext .db dbmopen_ext none dbmopen_haslock no to dbm_ext .db dbmopen_ext .db dbmopen_haslock no And execute './openwebmail-tool.pl --init' again! 修改 dbm.conf •[root@nat defaults]# pwd /var/www/cgi-bin/openwebmail/etc/defaults •[root@nat defaults]# vi dbm.conf dbm_ext .db dbmopen_ext .db dbmopen_haslock no 重新初始化 • [root@nat openwebmail]# ./openwebmail-tool.pl --init creating db /var/www/cgi-bin/openwebmail/etc/maps/b2g ...done. creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b ...done. creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar ...done. Welcome to the Open WebMail! This program is going to send a short message back to the developer, so we could have the idea that who is installing and how many sites are using this software, the content to be sent is: OS: Linux 2.4.20-30.9 i686 Perl: 5.008 WebMail: Open WebMail 2.41 20040926\ Send the site report?(Y/n) n Thank you. • [root@nat openwebmail]# Proxy Server Proxy Mail Server DNS Server 3 1 Web Server 2 4 5 Proxy Server 為何需要Proxy ? •目前 internet web 的使用量最大 •圖形,動畫,影音 •重複的流量佔頻寬 為何需要Proxy ? www.cisco.com proxy User2 User1 Proxy 的運作 proxy.nsysu.edu.tw ICP Parent www.cisco.com proxy.nknu.edu.tw child ICP sibling ICP child proxy.tf.edu.tw Proxy 範例說明 • [root@nat root]# rpm -qc squid /etc/logrotate.d/squid /etc/rc.d/init.d/squid /etc/squid/errors /etc/squid/mib.txt /etc/squid/mime.conf /etc/squid/msntauth.conf /etc/squid/squid.conf /etc/sysconfig/squid /etc/squid/squid.conf • cache_dir ufs /var/spool/squid 100 16 256 • http_access deny all • cache_peer parent_proxy parent 3128 3130 proxy-only • cache_access_log /var/log/squid/access.log 建立 Cache_dir •squid –z (only run at the first time) •cache_dir 建立,參考/etc/squid/squid.conf cache_dir ufs /var/spool/squid 100 16 256 Access Controls •增加 access security •squid.conf acl our_networks src 172.16.0.0/16 172.17.0.0/16 http_access allow our_networks Start porxy service • /etc/init.d/squid start Proxy Service check • /var/log/squid/access.log • /var/log/squid/cache.log • ps –aux | grep squid Client PC Proxy 設定 Client PC Proxy 設定 Q&A

Related docs
中文DNS介紹
Views: 15  |  Downloads: 0
動態DNS 介紹
Views: 23  |  Downloads: 0
DNS的介紹
Views: 1  |  Downloads: 0
TWNIC DNS 入門介紹
Views: 0  |  Downloads: 0
DNS 各種問題之探討與觀念介紹
Views: 30  |  Downloads: 0
Windows 2003 server 進階介紹
Views: 31  |  Downloads: 0
DNS 各種問題之探討與觀念介紹_1_
Views: 104  |  Downloads: 1
DNS 各種問題之探討與觀念介紹_2_
Views: 31  |  Downloads: 0
9-1、 Proxy伺服器的介紹
Views: 0  |  Downloads: 0
DNS TTL
Views: 241  |  Downloads: 8
DNS
Views: 90  |  Downloads: 16
DNS ___ ____ ___ ____
Views: 69  |  Downloads: 2
DNS __ __
Views: 5  |  Downloads: 0
______ – _________ DNS
Views: 13  |  Downloads: 0
premium docs
Other docs by vixycn
Yamaha motor viet nam co
Views: 14  |  Downloads: 0
YAMAHA MOTOR CORPORATION,CHINA
Views: 10  |  Downloads: 0
X1 SHAPE MOTOR
Views: 9  |  Downloads: 0
WIPO-IDB IP RYD 07 SMART-TURBINE
Views: 5  |  Downloads: 0
WINTON MOTOR RACEWAY PTY
Views: 5  |  Downloads: 0
Windshield Wiper Motor Replacement
Views: 8  |  Downloads: 0
Wind Turbine
Views: 10  |  Downloads: 0
WIND TURBINE VISIT
Views: 7  |  Downloads: 0
Wind Turbine Troubleshooting and Repair
Views: 7  |  Downloads: 0
Wind Turbine Troubleshooting and Repair(1)
Views: 8  |  Downloads: 0