11 · Introducing the TCP_IP Internet Layer, IPv4 Addressing, and Subnets認識 TCP/IP 網際網路層、IPv4 定址與子網路

Implementing Subnetting: Borrowing Bits實作子網路劃分:借用位元

Subnetting allows you to create multiple logical networks that exist within a single larger network. When you are designing a network addressing scheme, you need to be able to determine how many logical networks you will need and how many devices you will be able to fit into these smaller networks.

子網路劃分可讓你在單一較大型網路中建立多個邏輯網路。當你設計網路定址方案時,需要能夠判斷你需要多少個邏輯網路,以及這些較小的網路各能容納多少裝置。

To subnet a network address, you will borrow host bits and use them as subnet bits. You will use the subnet mask to indicate how many host bits have been borrowed. Bits must be borrowed consecutively, starting with the first host bit on the left. This approach introduces classless networks.

要對網路位址進行子網路劃分,你要借用主機位元並將其當作子網路位元使用,並利用子網路遮罩來表示借用了多少主機位元。位元必須從最左邊的第一個主機位元開始連續借用,此做法引入了無分類網路的概念。

To implement subnets, follow this procedure:

要實作子網路,請依照下列程序進行:

  • Determine the IP address for your network as assigned by the registry authority or network administrator.確定由註冊管理機構或網路管理員指派給你網路的 IP 位址。
  • Based on your organizational and administrative structure, determine the number of subnets that are required for the network. Be sure to plan for growth.根據你的組織與管理架構,判斷該網路所需的子網路數量,並務必為未來成長預作規劃。
  • Based on the required number of subnets, determine the number of bits that you need to borrow from the host bits.根據所需的子網路數量,判斷需要從主機位元中借用多少位元。
  • Determine the binary and decimal value of the new subnet mask that results from borrowing bits from the host ID.判斷從主機 ID 借用位元後所產生新子網路遮罩的二進位與十進位值。
  • Apply the subnet mask to the network IP address to determine the subnets and the available host addresses. Also, determine the network and broadcast addresses for each subnet.將子網路遮罩套用到網路 IP 位址,以判斷各子網路及可用的主機位址,同時判斷每個子網路的網路位址與廣播位址。
  • Assign subnet addresses to all subnets. Assign host addresses to all devices that are connected to each subnet.將子網路位址指派給所有子網路,並將主機位址指派給連接到各子網路的所有裝置。

Take a look at the following figure. The top table shows a standard Class C network address that is not subnetted. The bottom table shows the same address after it is subnetted by borrowing one host bit. Notice that the prefix length has changed from 24 to 25. The network IPv4 address itself is unchanged, although it is now considered a subnetwork (subnet) and is one of two subnets that have been created. The subnet mask has changed from 255.255.255.0 in decimal to 255.255.255.128, because the 128 bit is now turned on in the last octet.

請看下面的圖。上方的表格顯示未經子網路劃分的標準 C 類網路位址。下方的表格顯示同一位址在借用一個主機位元進行子網路劃分後的情況。請注意,前綴長度已從 24 變更為 25。網路 IPv4 位址本身並未改變,不過現在它被視為子網路(subnet),是所建立的兩個子網路之一。子網路遮罩已從十進位的 255.255.255.0 變更為 255.255.255.128,因為最後一個八位元組中的 128 位元現已開啟。

Each time that a bit is borrowed, the number of subnet addresses increases, and the number of host addresses that are available per subnet decreases. The algorithm that is used to compute the number of subnets and hosts uses powers of two. Therefore, borrowing one host bit enables you to create 21 = 2 subnets, borrowing 2 bits gives you 22 = 4 subnets, and so on.

每借用一個位元,子網路位址的數量就會增加,而每個子網路可用的主機位址數量則會減少。用來計算子網路與主機數量的演算法使用 2 的次方。因此,借用一個主機位元可讓你建立 21 = 2 個子網路,借用 2 個位元則可得到 22 = 4 個子網路,依此類推。

As the following figure shows, you can also determine how many host addresses are available per subnet when you borrow a given number of bits. Just like on a network, two addresses are not available to be used as host addresses on a subnet; they are used for the address of the subnet itself (with all of the host bits set to 0) and the directed broadcast address on the subnet (with all of the host bits set to 1). The figure shows that borrowing 1 bit for subnetting the address in the example leaves 7 bits for hosts.

如下圖所示,當你借用給定數量的位元後,也可以判斷每個子網路可用的主機位址數量。就如同在網路中一樣,子網路上有兩個位址無法用作主機位址,它們分別用作子網路本身的位址(所有主機位元皆設為 0)以及該子網路的定向廣播位址(所有主機位元皆設為 1)。此圖顯示,在此範例中借用 1 個位元進行子網路劃分,會留下 7 個位元供主機使用。

The formula to determine the number of hosts for this example is 27" 2, which calculates to 126 host addresses per subnet.

此範例判斷主機數量的公式為 27 − 2,計算結果為每個子網路 126 個主機位址。

Here is another example using the same network, in which five host bits are borrowed for subnetting. In this example, 25 = 32 subnets are created, and only 23 " 2 = 6 host addresses are available for each subnet. The new subnet mask is 11111111.11111111.11111111.11111000, which equates to 255.255.255.248 in decimal.

以下是使用同一網路的另一個範例,這次借用五個主機位元進行子網路劃分。在此範例中,會建立 25 = 32 個子網路,而每個子網路僅有 23 − 2 = 6 個可用的主機位址。新的子網路遮罩為 11111111.11111111.11111111.11111000,換算為十進位即為 255.255.255.248。

The following figure shows the subnetting of a Class B network address. The top table shows a network address with the default Class B subnet mask, 255.255.0.0. The second table shows the same address after it is subnetted by borrowing six host bits. Notice that the prefix length has changed from 16 to 22. The network IPv4 address itself is unchanged, but the subnet mask has changed from 255.255.0.0 in decimal to 255.255.252.0.

下圖顯示 B 類網路位址的子網路劃分。上方表格顯示套用預設 B 類子網路遮罩 255.255.0.0 的網路位址。第二個表格顯示同一位址在借用六個主機位元後的情況。請注意,前綴長度已從 16 變更為 22。網路 IPv4 位址本身並未改變,但子網路遮罩已從 255.255.0.0 變更為 255.255.252.0。

The next figure shows the subnetting of a Class A network address. The top table shows a network address with the default Class A subnet mask, 255.0.0.0. The bottom table shows the same address after it is subnetted by borrowing 8 host bits. Notice that the prefix length has changed from 8 to 16. The network IPv4 address is unchanged, but the subnet mask has changed from 255.0.0.0 in decimal to 255.255.0.0.

下一張圖顯示 A 類網路位址的子網路劃分。上方表格顯示套用預設 A 類子網路遮罩 255.0.0.0 的網路位址。下方表格顯示同一位址在借用 8 個主機位元後的情況。請注意,前綴長度已從 8 變更為 16。網路 IPv4 位址本身並未改變,但子網路遮罩已從 255.0.0.0 變更為 255.255.0.0。

How many host addresses can be used in a network with a /24 mask that has not been subnetted?在未經子網路劃分、遮罩為 /24 的網路中,可以使用多少個主機位址?
By borrowing three host bits, how many subnets are created?借用三個主機位元後,可以建立多少個子網路?
You have been assigned a /24 network address. A coworker has requested that you create 10 subnets that can support 10 hosts per network. Which subnet mask should you use?你被指派了一個 /24 網路位址。同事要求你建立 10 個能各自支援 10 台主機的子網路,你應該使用哪一個子網路遮罩?
You have subnetted your 192.168.36.0 network address with a 255.255.255.224 mask. How many subnets are available?你已使用 255.255.255.224 的遮罩對 192.168.36.0 網路位址進行子網路劃分,可用的子網路有幾個?
You have been assigned the network 172.16.0.0/16. You need to establish 13 subnets. What is the new subnet mask in the decimal form?你被指派了網路 172.16.0.0/16,需要建立 13 個子網路,新的子網路遮罩十進位形式為何?
A large company has a /8 network but needs to subnet it into 1000 subnets. Which subnet mask segments the /8 network and provides the maximum number of hosts per subnet?一家大型公司有一個 /8 網路,但需要將其劃分為 1000 個子網路。哪一個子網路遮罩能區隔此 /8 網路,並提供每個子網路最多的主機數量?
A company currently has a network range of 192.168.54.0/24. The company wants to subnet this range into 4 subnets, each supporting at least 50 users. Which subnet mask would you recommend?一家公司目前擁有網路範圍 192.168.54.0/24,該公司想將此範圍劃分為 4 個子網路,每個子網路至少支援 50 個使用者,你會建議使用哪一個子網路遮罩?