单臂路由——逻辑接口(详细传输过程!)

单臂路由

单臂路由(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   ##测试通信

用抓包查看传输的信息情况

单臂路由——逻辑接口(详细传输过程!)
单臂路由——逻辑接口(详细传输过程!)
单臂路由——逻辑接口(详细传输过程!)
单臂路由——逻辑接口(详细传输过程!)

谢谢阅读!

猜你喜欢

转载自blog.51cto.com/14080162/2447753