單臂路由

單臂路由-目標

     通過路由器進行多個VLAN互聯

 

單臂路由-環境

    

1. 交換機爲二層交換機,支持VLAN劃分;2. 路由器只有1個Ethernet接口

 

單臂路由-實施

    

採用單臂路由,即在路由器上設置多個邏輯子口,每個子接口對應於一個VLAN。由於物理路由接口只有一個,各子接口的數據在物理鏈路上傳遞要進行標記封裝。Cisco設備支持ISL和802.1q協議。華爲設備只支持802.1q。

單臂路由的配置實例

下面是我自己做的一個簡單的單臂路由的配置的過程,現在拿出來和大家一起分享。

理論我就不多說了,網上到處都是。但是關於詳細的介紹卻比較少。我就講每一步的步驟吧

設備如圖:pc機2臺分別爲 pc2和pc3、二層交換機1個爲 s1、路由器1個爲 R1

實驗拓撲實驗拓撲



首先開始配置pc機的ip地址pc2:192.168.2.10 pc3:192.168.3.10 掩碼都是24位的

網關可以到後面配置.這裏暫時不設置網關。

下面來配置交換機,分配好vlan。(簡單的我就不解釋了)

Switch>enable

Switch#vlan d
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.

Switch(vlan)#vlan 2 name test01
VLAN 2 added:
Name: test01
Switch(vlan)#vlan 3 name test02
VLAN 3 added:
Name: test02 →設置好vlan ,這裏只簡單設置兩個。

Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface fa0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface fa0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config)#interface fa0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
Switch(config-if)#exit

Switch(config)#end
%SYS-5-CONFIG_I: Configured from console by console
Switch#write memory
Building configuration...
[OK]

下面來重點,配置單臂路由:

Router>enable
Router#config
Configuring from terminal, memory, or network [terminal]?

Enter configuration commands, one per line. End with CNTL/Z. .................進入全局配置模式


Router(config)#interface fa0/0 ................進入和交換機連接的那個接口


Router(config-if)#no shutdown ................激活該端口


Router(config-if)#interface fa0/0.1 ...........配置 子接口 這是配置單臂路由的關鍵,這個接口是個 邏輯接口,並不是實際存在的物理接口,但是功能卻和物理接口是一樣的。


Router(config-subif)#ip address 192.168.2.1 255.255.255.0 .........爲該接口劃分ip地址。


Router(config-subif)#encapsulation dot1q 2 .......爲這個接口配置802.1Q協議,最後面的 2 是vlan 號,這也是關鍵部分


Router(config-subif)#exit


Router(config)#interface fa0/0.2 .....同樣,進入第2個子接口,進行配置


Router(config-subif)#ip address 192.168.3.1 255.255.255.0 ......劃分ip地址和子網掩碼


Router(config-subif)#encapsulation dot1q 3 .........配置802.1Q協議


Router(config-subif)#end
%SYS-5-CONFIG_I: Configured from console by console ..........完成配置

下面是測試結果:

經過分別對兩臺機子互相ping的測試,可以發現能夠ping通,說明實驗成功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章