首先我们了解一下什么是单臂路由:单臂路由是指在路由器的一个接口上通过配置子接口的方式,实现原来相互隔离的不同vlan(虚拟局域网)之间的互联互通。——————————————————————————
.
首先我们了解一下什么是单臂路由:单臂路由是指在路由器的一个接口上通过配置子接口的方式,实现原来相互隔离的不同vlan(虚拟局域网)之间的互联互通。
———————————————————————————————————————————————
单臂路由的子接口:
路由器的物理接口可以被划分成多个逻辑接口,这些被划分后的逻辑接口被形象的称为子接口。值得注意的是这些逻辑子接口不能被单独的开启或关闭,也就是说,当物理接口被开启或关闭时,所有的该接口的子接口也随之被开启或关闭。
单臂路由的优缺点:
vlan能有效分割局域网,实现各网络区域之间的访问控制。但现实中,往往需要配置某些vlan之间的互联互通。比如,例如:你的公司划分为领导层、销售部、财务部、人事部、技术部,并为不同部门配置了不同的vlan,部门之间不能相互访问,有效保证了各部门的信息安全。但经常出现领导层需要跨越Vvlan访问其他各个部门,这个功能就由单臂路由来实现。
优点:实现不同vlan之间的通信,有助理解、学习vlan原理和子接口概念。
缺点:容易成为网络单点故障,配置稍有复杂,现实意义不大。
Demo:
sw:
sw#conf t sw(config)#no ip routingsw(config)#vlan 10,20sw(config-vlan)#ex sw(config)#int f1/1sw(config-if)#sw mo accsw(config-if)#sw acc vlan 10sw(config-if)#int f1/2sw(config-if)#sw mo acc sw(config-if)#sw acc vlan 20sw(config-if)#do show vlan-sw bVLAN 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/1510 VLAN0010 active Fa1/120 VLAN0020 active Fa1/21002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup sw(config-if)#ex sw(config)#int f1/0sw(config-if)#sw mo tsw(config-if)#sw t en dotsw(config-if)#do show int f1/0 switchportName: Fa1/0Switchport: EnabledAdministrative Mode: trunkOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: DisabledAccess Mode VLAN: 0 ((Inactive))Trunking Native Mode VLAN: 1 (default)Trunking VLANs Enabled: ALLTrunking VLANs Active: 1,10,20Priority for untagged frames: 0Override vlan tag priority: FALSEVoice VLAN: none Appliance trust: none
R1配置单臂路由:
R1#conf tR1(config)#int f0/0.1 //配置子接口1R1(config-subif)#encapsulation dot1Q 10 //在vlan10中封装协议R1(config-subif)#ip add 192.168.10.1 255.255.255.0 //划分IP地址和子网R1(config-subif)#no shut //激活端口R1(config-subif)#exR1(config)#int f0/0.2 //配置子接口2R1(config-subif)#encapsulation dot1Q 20 //在vlan20中封装协议R1(config-subif)#ip add 192.168.20.1 255.255.255.0 //划分IP地址和子网R1(config-subif)#no shut //激活端口R1(config-subif)#exR1(config)#int f0/0 R1(config-if)#no shutR1(config-if)#endR1#show ip int bInterface IP-Address OK? Method Status ProtocolFastEthernet0/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#show ip routeCodes: C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, 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 routeGateway of last resort is not setC 192.168.10.0/24 is directly connected, FastEthernet0/0.1C 192.168.20.0/24 is directly connected, FastEthernet0/0.2//两个直连网段在这里
主机配置IP地址:
PC1> ip 192.168.10.10 192.168.10.1Checking for duplicate address...PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1PC2> ip 192.168.20.20 192.168.20.1Checking for duplicate address...PC1 : 192.168.20.20 255.255.255.0 gateway 192.168.20.1
测试互通并用Wireshark抓包:
PC1> ping 192.168.20.20 192.168.20.20 icmp_seq=1 timeout84 bytes from 192.168.20.20 icmp_seq=2 ttl=63 time=23.683 ms84 bytes from 192.168.20.20 icmp_seq=3 ttl=63 time=17.958 ms84 bytes from 192.168.20.20 icmp_seq=4 ttl=63 time=18.883 ms84 bytes from 192.168.20.20 icmp_seq=5 ttl=63 time=20.704 ms//此时是能够ping通的,说明单臂路由配置成功