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

Benefits of VLSM and Implementing VLSMVLSM 的優點與實作 VLSM

When you are using subnetting, the same subnet mask is applied for all the subnets of a given network. This way, each subnet has the same number of available host addresses. You may need this approach sometimes, but most organizations require several networks of various sizes rather than one network with thousands of devices. So usually, having the same subnet mask for all subnets of a given network ends up wasting address space because each subnet has the same number of available host addresses.

使用子網路劃分時,同一個網路的所有子網路都套用相同的子網路遮罩。如此一來,每個子網路的可用主機位址數量都相同。有時你可能需要這種做法,但大多數組織需要多個大小不一的網路,而不是一個擁有數千台裝置的網路。因此,為一個網路的所有子網路套用相同的子網路遮罩,通常會浪費位址空間,因為每個子網路的可用主機位址數量都一樣。

For example, in the following figure, Class B network 172.16.0.0 is subnetted by borrowing 8 host bits and applying a 24-bit subnet mask, allowing 256 subnets with 254 host addresses each. In this example, many host addresses are wasted. Each WAN link needs only two host addresses, so 252 host addresses are wasted on each WAN link. Many host addresses are also wasted on other subnets, and a Variable-length subnet mask (VLSM) provides a solution.

舉例來說,在下圖中,B 級網路 172.16.0.0 借用 8 個主機位元並套用 24 位元子網路遮罩進行子網路劃分,可提供 256 個子網路,每個子網路有 254 個主機位址。在此範例中,浪費了許多主機位址。每個 WAN 連結只需要兩個主機位址,因此每個 WAN 連結浪費了 252 個主機位址。許多其他子網路上也浪費了不少主機位址,而可變長度子網路遮罩(VLSM)提供了解決方案。

VLSM allows you to use more than one subnet mask within a network to efficiently use IP addresses. Instead of using the same subnet mask for all subnets, you can use the most efficient subnet mask for each subnet. The most efficient subnet mask for a subnet is the mask that provides an appropriate number of host addresses for that individual subnet. For example, subnet 172.16.6.0 has only 19 hosts, so it does not need the 254 host addresses that the 24-bit mask allows. A 27-bit mask would provide 30 host addresses, which is much more appropriate for this subnet.

VLSM 讓你能在同一個網路中使用多種子網路遮罩,以有效運用 IP 位址。你可以為每個子網路使用最合適的子網路遮罩,而不是對所有子網路使用相同的遮罩。子網路最合適的遮罩,是能為該個別子網路提供適當主機位址數量的遮罩。舉例來說,子網路 172.16.6.0 只有 19 台主機,所以不需要 24 位元遮罩所提供的 254 個主機位址。27 位元遮罩可提供 30 個主機位址,對這個子網路來說更為合適。

In the next figure, the 172.16.0.0/16 network is first divided into subnetworks using a 24-bit subnet mask. However, one of the subnetworks in this range, 172.16.14.0/24, is further divided into smaller subnetworks using a 27-bit mask to accommodate the subnets that have 19 or 28 hosts. These smaller subnetworks range from 172.16.14.0/27 to 172.16.14.224/27. Then, one of these smaller subnets, 172.16.14.128/27, is further divided using a 30-bit mask, which creates subnets with only two hosts to be used on the WAN links. The subnets with the 30-bit mask range from 172.16.14.128/30 to 172.16.14.156/30.

在下一張圖中,172.16.0.0/16 網路先以 24 位元子網路遮罩劃分成多個子網路。不過,此範圍中的其中一個子網路 172.16.14.0/24,又進一步以 27 位元遮罩劃分成更小的子網路,以容納有 19 或 28 台主機的子網路。這些較小的子網路範圍從 172.16.14.0/27 到 172.16.14.224/27。接著,其中一個較小的子網路 172.16.14.128/27,又進一步以 30 位元遮罩劃分,建立僅有兩台主機的子網路,供 WAN 連結使用。採用 30 位元遮罩的子網路範圍從 172.16.14.128/30 到 172.16.14.156/30。

In addition to providing a solution to the problem of wasted IP addresses, VLSM has another important benefit: support for route summarization, which is also called route aggregation. The hierarchical addressing design of VLSM enables easier summarization of network addresses. Route summarization reduces the number of routes in routing tables by representing a range of network subnets in a single summary address. Smaller routing tables require less CPU time for routing lookups.

除了解決 IP 位址浪費的問題外,VLSM 還有另一項重要優點:支援路由摘要(route summarization),也稱為路由聚合(route aggregation)。VLSM 的階層式定址設計讓網路位址更容易進行摘要。路由摘要藉由用單一摘要位址代表一段範圍的網路子網路,來減少路由表中的路由數量。較小的路由表在進行路由查詢時,需要的 CPU 時間也較少。

In the previous figure, the subnet 172.16.14.0/24 describes all the addresses that are further subnets of 172.16.14.0, including those addresses from subnet 172.16.14.0/27 to subnet 172.16.14.128/30.

在前一張圖中,子網路 172.16.14.0/24 描述了 172.16.14.0 進一步劃分出的所有子網路位址,包括從子網路 172.16.14.0/27 到子網路 172.16.14.128/30 的所有位址。

VLSM is an important technology in large routed networks. VLSM can be used in all modern networks that run classless routing protocols such as Routing Information Protocol version 2 (RIPv2), Open Shortest Path First (OSPF), and Enhanced Interior Gateway Routing Protocol (EIGRP). However, VLSM could not be used on a network using legacy classful protocols such as Routing Information Protocol version 1 (RIPv1) and Interior Gateway Routing Protocol (IGRP). Those protocols cannot carry subnet mask information on their routing updates and are no longer used in today's networks.

VLSM 是大型路由網路中的重要技術。VLSM 可用於所有執行無級別路由協定(classless routing protocol)的現代網路,例如路由資訊協定第 2 版(RIPv2)、開放最短路徑優先(OSPF)以及增強型內部閘道路由協定(EIGRP)。不過,VLSM 無法用於使用傳統有級別協定(classful protocol)的網路,例如路由資訊協定第 1 版(RIPv1)與內部閘道路由協定(IGRP)。這些協定無法在其路由更新中攜帶子網路遮罩資訊,如今已不再被使用。

Implementing VLSM

實作 VLSM

The network 172.16.0.0 has already been subnetted by applying a 20-bit subnet mask. One of the resulting subnet addresses, 172.16.32.0/20, is used for the region of the enterprise network that the following figure shows. This region needs to assign addresses to multiple LANs. Each LAN must have 50 hosts. You can use VLSM to further subnet the address 172.16.32.0/20 to give you more subnet addresses with fewer hosts per subnet.

網路 172.16.0.0 已套用 20 位元子網路遮罩進行子網路劃分。其中一個產生的子網路位址 172.16.32.0/20,用於下圖所示的企業網路區域。此區域需要為多個 LAN 指派位址,每個 LAN 都必須有 50 台主機。你可以使用 VLSM 進一步劃分位址 172.16.32.0/20,以取得更多子網路位址,且每個子網路的主機數更少。

The next figure shows in binary the original subnetting of the 172.16.0.0/16 network to /20 by borrowing 4 host bits, which provided 16 subnets with 4094 host addresses each. The figure also shows how to further subnetting with VLSM increases the number of subnets and provides the desired number of host addresses per subnet. Borrowing an additional 6 subnet bits results in an additional 26 = 64 subnets. This leaves 6 host bits, resulting in 26 " 2 = 62 hosts on each of these subnets.

下一張圖以二進位顯示 172.16.0.0/16 網路原先借用 4 個主機位元劃分為 /20 的情形,提供 16 個子網路,每個子網路有 4094 個主機位址。此圖也顯示如何透過 VLSM 進一步劃分子網路,以增加子網路數量並提供所需的每個子網路主機位址數。再借用 6 個子網路位元會產生額外的 26 = 64 個子網路。這樣會剩下 6 個主機位元,使每個子網路有 26 " 2 = 62 台主機。

The following figure shows the subnet addresses and host addresses that are achieved by using VLSM. The subnet for the region in this example, subnet 172.16.32.0/20, is further subnetted by applying a 26-bit mask, as the previous figure shows.

下圖顯示使用 VLSM 所取得的子網路位址與主機位址。此範例中該區域的子網路,即子網路 172.16.32.0/20,如前圖所示,進一步套用 26 位元遮罩劃分子網路。

The following figure shows some of the new VLSM subnet addresses that are applied to the regional network.

下圖顯示套用到此區域網路的部分新 VLSM 子網路位址。

To calculate the subnet addresses for the WAN links, further subnet one of the unused /26 subnets with a 30-bit subnet mask. For this example, subnet 172.16.33.0/26 will be further subnetted. Borrowing an additional 4 subnet bits results in an additional 24 = 16 subnets. This leaves 2 host bits, resulting in 22" 2 = 2 hosts on each subnets.

若要計算 WAN 連結的子網路位址,需再以 30 位元子網路遮罩,對其中一個未使用的 /26 子網路進一步劃分子網路。在此範例中,子網路 172.16.33.0/26 將被進一步劃分。再借用 4 個子網路位元會產生額外的 24 = 16 個子網路。這樣會剩下 2 個主機位元,使每個子網路有 22" 2 = 2 台主機。

The following figure shows all the new VLSM subnet addresses that are applied to the regional network.

下圖顯示套用到此區域網路的所有新 VLSM 子網路位址。

As seen in this example, where we used VLSM to further subnet the address 172.16.32.0/20 into smaller subnets of different sizes, the easiest way to assign the subnets is to assign the subnets with the largest number of hosts first.

如此範例所示,我們使用 VLSM 將位址 172.16.32.0/20 進一步劃分為大小不一的較小子網路,最簡單的指派方式是先指派主機數最多的子網路。

You are designing an IPv4 addressing scheme for a branch office. The branch office is assigned to the 192.168.1.64/26 subnetwork, so you have one subnet (192.168.1.64) with 62 host addresses that are available to you. You need at least 4 subnets with 14 hosts each. Which subnet mask should you use to achieve the desired scheme?你正在為分公司設計 IPv4 定址方案。該分公司被指派 192.168.1.64/26 子網路,因此你擁有一個子網路(192.168.1.64),可用主機位址有 62 個。你至少需要 4 個子網路,每個子網路各 14 台主機。你應該使用哪個子網路遮罩來達成所需的方案?
Refer to the figure. Which two subnet addresses should be used for Subnets 1 and 2? (Choose two.)請參閱圖片。子網路 1 與子網路 2 應該使用哪兩個子網路位址?(選擇兩項。)