您的位置:首页 > 其它

Cisco单臂路由

2019-10-20 08:10 1546 查看

首先我们了解一下什么是单臂路由:单臂路由是指在路由器的一个接口上通过配置子接口的方式,实现原来相互隔离的不同vlan(虚拟局域网)之间的互联互通。

———————————————————————————————————————————————

单臂路由的子接口:

路由器的物理接口可以被划分成多个逻辑接口,这些被划分后的逻辑接口被形象的称为子接口。值得注意的是这些逻辑子接口不能被单独的开启或关闭,也就是说,当物理接口被开启或关闭时,所有的该接口的子接口也随之被开启或关闭。

单臂路由的优缺点:

vlan能有效分割局域网,实现各网络区域之间的访问控制。但现实中,往往需要配置某些vlan之间的互联互通。比如,例如:你的公司划分为领导层、销售部、财务部、人事部、技术部,并为不同部门配置了不同的vlan,部门之间不能相互访问,有效保证了各部门的信息安全。但经常出现领导层需要跨越Vvlan访问其他各个部门,这个功能就由单臂路由来实现。

优点:实现不同vlan之间的通信,有助理解、学习vlan原理和子接口概念。

缺点:容易成为网络单点故障,配置稍有复杂,现实意义不大。

Demo:

sw:

sw#conf t
sw(config)#no ip routing
sw(config)#vlan 10,20
sw(config-vlan)#ex
sw(config)#int f1/1
sw(config-if)#sw mo acc
sw(config-if)#sw acc vlan 10
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 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
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)#ex
sw(config)#int f1/0
sw(config-if)#sw mo t
sw(config-if)#sw t en dot
sw(config-if)#do show int f1/0 switchport
Name: Fa1/0
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1,10,20
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none

R1配置单臂路由:

R1#conf t
R1(config)#int f0/0.1       //配置子接口1
R1(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)#ex
R1(config)#int f0/0.2       //配置子接口2
R1(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)#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#show ip route
Codes: 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 route

Gateway of last resort is not set

C    192.168.10.0/24 is directly connected, FastEthernet0/0.1
C    192.168.20.0/24 is directly connected, FastEthernet0/0.2
//两个直连网段在这里

主机配置IP地址:

PC1> ip 192.168.10.10 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1

PC2> ip 192.168.20.20 192.168.20.1
Checking 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 timeout
84 bytes from 192.168.20.20 icmp_seq=2 ttl=63 time=23.683 ms
84 bytes from 192.168.20.20 icmp_seq=3 ttl=63 time=17.958 ms
84 bytes from 192.168.20.20 icmp_seq=4 ttl=63 time=18.883 ms
84 bytes from 192.168.20.20 icmp_seq=5 ttl=63 time=20.704 ms
//此时是能够ping通的,说明单臂路由配置成功
源IP是10.10,目标IP是20.20,此时经过交换机判断是vlan10端口传过来的信息,就会给它打上ID:10的标签,此时抓包我们就会看到

R1查看路由表之后知道传输给20段,此时会做标签的转换,由原来的ID:10变成ID:20

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: