單臂路由
單臂路由(router-on-a-stick)是指在路由器的一個接口上通過配置子接口(或“邏輯接口”,並不存在真正物理接口)的方式,實現原來相互隔離的不同VLAN(虛擬局域網)之間的互聯互通。
優缺點
優點:實現不同vlan之間的通信,有助理解、學習VLAN原理和子接口概念。
缺點:容易成爲網絡單點故障,配置稍有複雜,現實意義不大。
實驗拓撲圖
實驗環境
vlan10:pc1(192.168.10.10/24)
vlan20:pc2(192.168.20.20/24)
實驗目的
實現不同vlan之間的通信
1,配置sw二層交換機
sw#conf t ##進入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
sw(config)#no ip routing ##關閉路由功能
sw(config)#vlan 10,20 ##創建vlan10 20
sw(config-vlan)#ex
sw(config)#int f1/1 ##進入接口
sw(config-if)#sw mod acc ##創建接入鏈路
sw(config-if)#sw acc vlan 10 ##將接口放到vlan中
sw(config-if)#int f1/2
sw(config-if)#sw mo acc
sw(config-if)#sw acc vlan 20
sw(config-if)#do show vlan-sw b ##查看vlan信息
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa1/0, Fa1/3, Fa1/4, Fa1/5
Fa1/6, Fa1/7, Fa1/8, Fa1/9
Fa1/10, Fa1/11, Fa1/12, Fa1/13
Fa1/14, Fa1/15
10 VLAN0010 active Fa1/1 ##接口放到對應vlan中
20 VLAN0020 active Fa1/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
sw(config-if)#int f1/0 ##進入到f1/0接口中
sw(config-if)#sw mo tr ##設置爲trunk鏈路
sw(config-if)#sw tr en dot
sw(config-if)#do show int f1/0 switchport ##查看看接口信息
2,配置R1路由器
R1#conf t ##全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0.1 ##進入邏輯子接口
R1(config-subif)#encapsulation dot1Q 10 ##封裝協議vlan10
R1(config-subif)#ip add 192.168.10.1 255.255.255.0 ##設置網關
R1(config-subif)#no shut ##開啓
R1(config-subif)#ex
R1(config)#int f0/0.2
R1(config-subif)#encapsulation dot1Q 20 ##封裝協議vlan20
R1(config-subif)#ip add 192.168.20.1 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#ex
R1(config)#int f0/0 ##進入物理接口
R1(config-if)#no shut ##開啓
R1(config-if)#end
R1#show ip int b ##查看接口信息
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset up up
FastEthernet0/0.1 192.168.10.1 YES manual up up
FastEthernet0/0.2 192.168.20.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
R1#sho ip route ##查看路由表
C 192.168.10.0/24 is directly connected, FastEthernet0/0.1
C 192.168.20.0/24 is directly connected, FastEthernet0/0.2
3,用測試機測試不同vlan中間通信
PC1> ip 192.168.10.10 192.168.10.1 ##設置pc1的地址和網關
PC2> ip 192.168.20.20 192.168.20.1 ##設置pc2的地址和網關
PC1> ping 192.168.20.20 ##測試通信