一、實驗目標
- 掌握單臂路由配置方法;
- 通過單臂路由實現不同VLAN間互相通信;
二、實驗背景
某企業有兩個主要部門:技術部和銷售部,分處於不同的辦公室,為了安全和便於管理,對兩個部門的主機進行了VLAN的划分,技術部和銷售部分處於不同的VLAN。現由於業務的需求,需要銷售部和技術部的主機能夠相互訪問,獲得相應的資源,兩個部門的交換機通過一台路由器進行了連接。
三、技術原理
單臂路由:是為實現VLAN間通信的三層網絡設備路由器,它只需要一個以太接口,通過創建子接口可以承擔所有VLAN的網關,而在不同的VLAN間轉發數據。
四、實驗步驟
實驗拓撲

1、當交換機設置成兩個vlan時,邏輯上已經成為兩個網絡,廣播被隔離了。兩個vlan的網絡要通信,必須通過路由器,如果接入路由器的只有一個物理端口,則必須有兩個子接口分別與兩個vlan對應,同時還要求與路由器相連的交換機的端口f0/1要設置為trunk,因為這個口要通過兩個vlan的數據包。
2、檢查設置情況,應該能正確的看到vlan和trunk的信息。
3、計算機的網關分別指向路由器的子接口。
4、配置子接口,開啟路由器物理接口。
5、默認封裝為dot1q協議。
6、配置路由器子接口ip地址。
Switch:
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
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)#
R1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1
R1(config)#interface fa0/0
R1(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#exit
R1(config)#interface fa0/0.1
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to up
R1(config-subif)#encapsulation dot1Q 2
R1(config-subif)#ip address 192.168.1.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fa0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up
R1(config-subif)#encapsulation dot1Q 3
R1(config-subif)#ip address 192.168.2.1 255.255.255.0
R1(config-subif)#
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/0.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0.2
R1
五、測試
PC2:
Packet Tracer PC Command Line 1.0
PC>ipconfig
IP Address......................: 192.168.2.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.2.1
PC>ping 192.168.1.2
Pinging 192.168.1.2 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.2: bytes=32 time=8ms TTL=127
Reply from 192.168.1.2: bytes=32 time=8ms TTL=127
Reply from 192.168.1.2: bytes=32 time=17ms TTL=127
Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 8ms, Maximum = 17ms, Average = 11ms
PC>
