© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 Chapter 4 IP 定址:分級式定址
4 - 2 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 目標 本章結束後,您將能夠: 了解 IPv4 的位址與等級 辨識 IP 位址的等級 找出任一個 IP 位址所在的網路位址 了解遮罩及其使用方式 了解子網路及超網路
4 - 3 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 簡介 本節所討論的主題包括: 位址空間 表示法 在 TCP/IP 通訊協定組的 IP 層裡,用來辨識每台電腦的 東西,稱為網際網路位址 ( Internet address ) 或 IP 位址 ( IP address ) 。 IP 位址是一個 32 位元的二進制數字,具有全域性,用來 唯一的定義 Internet 上的一台電腦或一台路由器。 所有 IP 位址都是唯一的。「唯一」是指一個位址只定義 一個與 Internet 的連接 ( connection ) 。 Internet 上不可以有 兩台裝置有著相同的 IP 位址。
4 - 4 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 一個 IP 位址為一個 32 位元的位址。 請注意:
4 - 5 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 IP 位址是唯一的。 請注意:
4 - 6 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 IPv4 的位址空間為 2 32 或 4,294,967,296 。 請注意:
4 - 7 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
4 - 8 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 1 解答 我們將每個 8 位元的群組分別改成等效的十進制數字,並 用英文句點加以隔開。 a) b) c) d) 將下列 IP 位址從二進制表示法改為點式十進制表示法。 a) b) c) d)
4 - 9 © The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 2 解答 我們將每個十進制數字分別改成等效的二進制數字。 a) b) c) d) 將下列 IP 位址從點式十進制表示法改為二進制表示法。 a) b) c) d)
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 3 解答 a) 以點式十進制表示,數字前面不用加零 ( 045 ) 。 b)IP 位址不可以超過 4 個數字。 c) 以點式十進制表示,最大值為 255 ,但 301 大於 255 的範圍。 d) 不可以將二進制及點式十進制混合使用。 將下列 IP 位址的錯誤找出來。 a) b) c) d)
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 4 解答 我們將每 4 個位元以其等效十六進制數字取代。注意十六進 制表示法,通常不會加入空白或句點。不過,可以在前面 加入 0X ( 或 0x ) 或以下標 16 說明數字為十六進制。 a)0X810B0BEF 或 810B0BEF 16 b)0XC1831BFF 或 C1831BFF 16 將下列 IP 位址從二進制表示法改為十六進制表示法。 a) b)
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 分級式定址 本節所討論的主題包括: 等級的分辨 網路代碼與主機代碼 等級和區塊 網路位址 足夠的資訊 遮罩 CIDR 表示法 位址耗盡 IP 位址在幾十年前開始時,使用等級 ( class ) 的觀念。這 種架構稱為分級式定址 ( classful addressing ) 。 在 1990 年代中期,一種新的架構稱為無級式定址 ( classless addressing ) 被提出來。這個架構最終將會取代原來的分級 式架構。 儘管部份的 Internet 依舊是使用分級式定址,但轉變程序 進行的相當快。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 5 我們如何證明等級 A 有 2,147,483,648 個位址。 解答 在等級 A 中,只有一個位元定義其等級。 剩下的 31 個位元可以作為定址用。 所以 2 31 = 2,147,483,648 個位址。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 6 解答 見圖 4.4 的步驟。 a) 第一個位元 0 ,這是等級 A 位址。 b) 最前兩個位元為 1 ,第三個位元為 0 ,這是等級 C 位址。 c) 最前一個位元 0 ,第二個位元為 1 ,這是等級 B 位址。 d) 最前四個位元為 1 ,這是等級 E 位址。 找出下列各位址的等級。 a) b) c) d)
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 7 找出下列位址的等級。 a) b) c) d) e) 解答 a) 第一個位元組 227 ( 在 224 和 239 之間 ) ;等級是 D 。 b) 第一個位元組 193 ( 在 192 和 223 之間 ) ;等級是 C 。 c) 第一個位元組 14 ( 在 0 和 127 之間 ) ;等級是 A 。 d) 第一個位元組 252 ( 在 240 和 255 之間 ) ;等級是 E 。 e) 第一個位元組 134 ( 在 128 和 191 之間 ) ;等級是 B 。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 8 在範例 5 ,我們證明等級 A 的位址有 2 31 個,如果改以點式十 進制表示,要如何證明呢? 解答 等級 A 的位址範圍從 到 。我們必須 證明這二個數值之差為 2,147,483,648 。這是一個很好的題 目,因為它說明二個位址之間的範圍有多大。我們注意到, 這是基底 ( base ) 為 256 的數字,每個位元組有一個權重。 分別是:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 8 ( 續 ) 要找出每個數目之整數值,我們將每個位元組乘以其權重: 將上面第一個數字減第二個數字再加 1 , 我們得到 2,147,483,648 即 2 31 。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 很多等級 A 的位址都被浪費掉。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 不少等級 B 的位址都被浪費掉。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 等級 C 的位址數目對大多數使用單位來講, 可能都太少。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 等級 D 的位址做為群播之用,只有一個區塊。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 等級 E 的位址保留給特定之用途, 但大部分的位址都被浪費掉了。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 在分級式定址架構中,核給使用單位的位址, 即為網路位址 ( 區塊的第一個位址 ) 。 給予一個網路位址,我們可以從這個位址, 自動推算出來網路的位址範圍。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 9 解答 這是等級 A 的位址,因為第一個位元組在 0 到 127 之間。 區塊的 Netid 為 17 , 位址範圍從 到 。 給予網路位址 ,找出其等級、區塊、與位址範圍。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 10 解答 這是等級 B 的位址,因為第一個位元組在 128 到 191 之間。 區塊的 Netid 為 , 位址範圍從 到 。 給予網路位址 ,找出其等級、區塊、與位址範圍。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 11 解答 這是等級 C 的位址,因為第一個位元組在 192 到 223 之間。 區塊的 Netid 為 , 位址範圍從 到 。 給予網路位址 ,找出其等級、區塊、與位址範圍。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 網路位址為每一個區塊的起始位址, 可藉由預設遮罩而獲得 ( 包括它自己 ) 。 它保留了區塊的 Netid ,並且將 Hostid 設為 0 。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 12 解答 預設遮罩為 ,表示第一個位元組被保留,其他三 個位元組則設為 0 。所以網路位址為 。 給予位址 ,找出其區塊起始位址 ( 網路位址 ) 。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 13 解答 預設遮罩為 ,表示前二個位元組被保留,其他 二個位元組則設為 0 。所以網路位址為 。 給予位址 ,找出其區塊起始位址 ( 網路位址 ) 。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 14 解答 預設遮罩為 ,表示前三個位元組被保留,剩 下一個位元組則設為 0 。所以網路位址為 。 給予位址 ,找出其區塊起始位址 ( 網路位址 ) 。
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 注意,我們不可以將某一等級的預設遮罩, 用到屬於其他等級的位址。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 其他議題 在本節中,我們介紹其他與定址相關的議題,特別是有關分 級式定址的議題。 本節所討論的主題包括: 多重位址裝置 IP 是地點,不是名字 特殊位址 私有位址 單點傳播、群播及廣播位址
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 在第 15 章,會有更多關於群播傳遞的介紹。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 子網路化 與超網路化 在前一節,我們討論到分級式定址的相關問題,尤其是剩下 來可供申請的網路位址幾乎耗盡。然而,還有很多組織單位 想要連上 Internet 。在本節中,我們會介紹二種解決方法: 子網路化 ( subnetting ) 與超網路化 ( supernetting ) 。 本節所討論的主題包括: 子網路化 超網路化 超網路遮罩 陳舊過時
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 IP 位址設計為兩個階層。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 範例 15 解答 將位址與子網路遮罩做 AND 運算 所以子網路位址為 。 如果目的位址為 ,子網路遮罩為 , 則子網路位址為何?
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 實現子網路時,我們需要子網路的第一個位址 與子網路遮罩以定義該子網路的位址範圍。 實現超網路時,我們需要超網路的第一個位址 與超網路遮罩以定義該超網路的位址範圍。 請注意:
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007
© The McGraw-Hill Companies, Inc., 2006© The McGraw-Hill Companies, Inc., 2007 分級式定址中 子網路化與超網路化的概念幾乎被淘汰。 請注意: