20 · Routing Between VLANsVLAN 間路由

Purpose of Inter-VLAN RoutingVLAN 間路由的目的

Each VLAN is a unique Layer 2 broadcast domain. Devices on separate VLANs are, by default, not able to communicate. Each VLAN is usually assigned to a different IP subnet, which is a Layer 3 broadcast domain. You can permit these devices to communicate by using a solution that is called inter-VLAN routing. Inter-VLAN communication occurs between subnets via a Layer 3 device.

每個 VLAN 都是獨立的第 2 層廣播網域,不同 VLAN 上的裝置預設無法互相通訊。每個 VLAN 通常會指派給不同的 IP 子網路,也就是第 3 層廣播網域。你可以透過一種稱為VLAN 間路由的解決方案,讓這些裝置能夠通訊。VLAN 間通訊是透過第 3 層裝置在子網路之間進行的。

VLANs have the following characteristics:

VLAN 具有以下特性:

  • A VLAN creates a separate Layer 2 broadcast domain.VLAN 會建立一個獨立的第 2 層廣播網域。
  • Traffic cannot be switched between VLANs.流量無法在 VLAN 之間直接交換。
  • Each VLAN is mapped to a separate IP subnet.每個 VLAN 都對應到一個獨立的 IP 子網路。
  • Routing is necessary to forward traffic between VLANs.必須透過路由才能在 VLAN 之間轉送流量。

VLANs perform network partitioning and traffic separation at Layer 2 and are usually associated with unique IP subnets on the network, as illustrated in the figure for IPv4 subnets. This subnet configuration facilitates the routing process in a multi-VLAN environment. Inter-VLAN communication cannot occur without a Layer 3 device. Layer 3 switches or routers perform inter-VLAN routing by either having a separate router interface for each VLAN, or by using a trunk to carry traffic for all VLANs. The devices on the VLANs send traffic through the router to reach other VLANs.

VLAN 在第 2 層執行網路分割與流量隔離,通常會與網路中獨立的 IP 子網路相關聯,如圖中 IPv4 子網路所示。這種子網路組態有助於在多 VLAN 環境中進行路由處理。若沒有第 3 層裝置,VLAN 間通訊便無法發生。第 3 層交換器或路由器可透過為每個 VLAN 提供獨立的路由器介面,或使用中繼來承載所有 VLAN 的流量,來執行 VLAN 間路由。VLAN 上的裝置會透過路由器傳送流量,以到達其他 VLAN。

To allow communication between different VLANs, inter-VLAN routing is needed. If two hosts belong to two different VLANs, they also belong to two different subnets. For communication between two hosts on different subnets, you need a Layer 3 device.

若要允許不同 VLAN 之間互相通訊,就需要 VLAN 間路由。如果兩台主機屬於兩個不同的 VLAN,它們也屬於兩個不同的子網路。要在不同子網路上的兩台主機之間通訊,你需要一台第 3 層裝置。

PC1 and PC2 belong to VLAN 10 and PC3 and PC4 belong to VLAN 20. PC1 and PC2 can send packets to each other directly because they are on the same broadcast domain. The same goes for PC3 and PC4. If PC1 wants to send data to PC3, it requires inter-VLAN routing. PC1 checks the destination IP address and determines that PC3 belongs to a different subnet. PC1 sends the data to its default gateway when the destination IP address belongs to another subnet. The default gateway for each VLAN (VLAN 10 and VLAN 20) is configured on the Layer 3 device. The Layer 3 device (it can be a router or a Layer 3 switch) can route the traffic between the different subnets because the subnets are directly connected networks. The networks appear as directly connected because the default gateway IP addresses are configured on the interfaces. When the Layer 3 device receives the data from PC1, it checks the routing table to find the outgoing interface to reach the destination. It is the role of the Layer 3 device to enable PC1 and PC3 inter-VLAN communication.

PC1 與 PC2 屬於 VLAN 10,PC3 與 PC4 屬於 VLAN 20。PC1 與 PC2 可以直接互相傳送封包,因為它們位於同一個廣播網域中,PC3 與 PC4 也是如此。如果 PC1 想要將資料傳送給 PC3,就需要 VLAN 間路由。PC1 會檢查目的 IP 位址,判斷 PC3 屬於不同的子網路。當目的 IP 位址屬於另一個子網路時,PC1 會將資料傳送到其預設閘道。每個 VLAN(VLAN 10 與 VLAN 20)的預設閘道都設定在第 3 層裝置上。由於這些子網路都是直接連接的網路,第 3 層裝置(可以是路由器或第 3 層交換器)便能在不同子網路之間路由流量。由於預設閘道 IP 位址是設定在介面上的,這些網路才會顯示為直接連接。當第 3 層裝置從 PC1 收到資料時,會查詢路由表以找出到達目的地的送出介面。啟用 PC1 與 PC3 之間 VLAN 間通訊的角色,正是由第 3 層裝置來扮演。

Which statement regarding VLANs is true?關於 VLAN,以下哪項敘述正確?