单臂路由:是指在路由器的一个接口上配置子接口的方式 实现跨VLAN通信
实验环境
- Cisco Packet Tracer 6.0
- 1台2811路由器
- 1台2960交换机
- 4台PC
拓扑图
实验要求
设备名称 | VLAN | IP | 子网掩码 |
---|---|---|---|
PC1 | 10 | 192.168.85.2 | 255.255.255.0 |
PC2 | 10 | 192.168.85.3 | 255.255.255.0 |
PC3 | 20 | 192.168.15.2 | 255.255.255.0 |
PC4 | 20 | 192.168.15.3 | 255.255.255.0 |
VLAN | IP | 子网掩码 |
---|---|---|
VLAN 10(名称为srou2) | 192.168.85.1 | 255.255.255.0 |
VLAN 20(名称为srou3) | 192.168.15.1 | 255.255.255.0 |
- 配置路由器单臂路由使得VLAN10和20相互通信
# 交换机:
Switch>en //进入特权模式
Switch#conf t //进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10 //创建VLAN10
Switch(config-vlan)#name srou2 //设置VLAN10名称
Switch(config-vlan)#exit //退出VLAN10
Switch(config)#vlan 20 //创建VLAN20
Switch(config-vlan)#name srou3 //设置VLAN20名称
Switch(config-vlan)#exit //退出VLAN20
Switch(config)#int ra fa0/2-3 //选择fa0/2和fa0/3口
Switch(config-if-range)#sw ac vlan 10 //将fa0/2和fa0/3划分给VLAN10
Switch(config-if-range)#int ra fa0/12-13 //选择fa0/12和fa0/13口
Switch(config-if-range)#sw ac vlan 20 //将fa0/12和fa0/13划分给VLAN20
Switch(config-if-range)#int fa0/1 //进入fa0/1口
Switch(config-if)#sw mode tr //将fa0/1口工作模式设置为trunk
Switch(config-if)#no shut //开启fa0/1口
Switch(config-if)#end //返回特权模式
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#
# 路由器:
Router>en //进入特权模式
Router#conf t //进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa0/0 //进入fa0/0口
Router(config-if)#no shut //开启fa0/0
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#int fa0/0.1 //进入fa0/0口第1子接口
Router(config-subif)#
%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
Router(config-subif)#encap dot1Q 10 //将该子接口封装格式为802.1q给VLAN10
Router(config-subif)#ip add 192.168.85.1 255.255.255.0 //设置该子接口ip
Router(config-subif)#int fa0/0.2 //进入fa0/0口第2子接口
Router(config-subif)#
%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
Router(config-subif)#encap dot 20 //将该子接口封装格式为802.1q给VLAN20
Router(config-subif)#ip add 192.168.15.1 255.255.255.0 //设置该子接口ip
Router(config-subif)#end //返回特权模式
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#
以上就配置完成了路由器单臂路由
接下来使用PC机ping命令进行连通性测试
PC1 ping PC2 Reply
PC1 ping PC3 Reply
PC1 ping PC4 Reply
ping成功啦