橋接工作於 OSI 第 2 層,依 MAC 地址轉發幀,可將不同物理介面(Serial、Ethernet)橋接為同一廣播域。Cisco 路由器支援 IRB (Integrated Routing and Bridging),同一 Bridge Group 內可同時進行橋接轉發與第 3 層路由。本文提供完整配置範例與關鍵指令解析。
version 12.1
hostname Router-Bridge
no ip routing ! 僅做橋接時關閉;若啟用 IRB 則保留 ip routing
!
bridge 1 protocol ieee
bridge 1 route ip ! IRB:橋接群組 1 內支援 IP 路由
!
interface Serial0
description 128k Leased Line to Branch
ip address 198.127.18.4 255.255.255.0
no ip route-cache
bridge-group 1
!
interface FastEthernet0
ip address 198.127.18.3 255.255.255.0
no ip route-cache
speed auto
bridge-group 1
!
! 若啟用 IRB 需建立 BVI 介面作為第 3 層閘道
interface BVI1
ip address 192.168.100.1 255.255.255.0
!
ip classless
no ip http server
!
line con 0
transport input none
line vty 0 4
password csl
login
end
| 指令 | 說明 |
|---|---|
bridge 1 protocol ieee | 啟用 STP (802.1D),防止橋接環路 |
bridge 1 route ip | 開啟 IRB,允許橋接域內 IP 路由 |
bridge-group 1 | 介面加入 Bridge Group 1 |
interface BVI1 | 橋接虛擬介面,作為該橋接域的 L3 閘道 |
show spanning-tree | 檢視 STP 狀態、Root Bridge、Port Role |
show bridge | 顯示橋接表(MAC、介面、老化時間) |
bridge 1 hello-time 10、bridge 1 max-age 40。