VLAN间的通信
在企业中,不同的VLAN之间需要隔离广播域,但是也是存在通信的需要的,不过需要在可控情况下进行通信。
如果需要对流量进行识别和管控,往往需要三层到七层流量的审查能力的设备。
单臂路由
![image-20200425134804446](/2020/04/25/san-ceng-jiao-huan/image-20200425134804446.png)
![image-20200425135946404](/2020/04/25/san-ceng-jiao-huan/image-20200425135946404.png)
![image-20200425134404728](/2020/04/25/san-ceng-jiao-huan/image-20200425134404728.png)
如图所示,R2和R3分别属于不同的VLAN中的PC。R2和R3想要通信可以通过R1来进行。
Sw(config)#vlan 10,20
Sw(config-vlan)#int e0/2
Sw(config-if)#sw ac vl 10
Sw(config-if)#int e0/3
Sw(config-if)#sw ac vl 20
Sw(config-if)#int e0/1
Sw(config-if)#sw tr en do
Sw(config-if)#sw mo tr
================================
R2(config)#no ip routing
R2(config)#int e0/0
R2(config-if)#ip add 192.168.10.1 255.255.255.0
R2(config-if)#no sh
================================
R3(config)#no ip routing
R3(config)#int e0/0
R3(config-if)#ip add 192.168.20.1 255.255.255.0
R3(config-if)#no sh
================================
R1(config)#int e0/0
R1(config-if)#no sh
R1(config-if)#int e0/0.10
R1(config-subif)#en do 10
R1(config-subif)#ip add 192.168.10.254 255.255.255.0
R1(config-subif)#int e0/0.20
R1(config-subif)#en do 20
R1(config-subif)#ip add 192.168.20.254 255.255.255.0
最终检查是否可以通信
R2(config-if)#do ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/3 ms
由于流量来回占用了同一根线路,会造成带宽的瓶颈,并且线路故障会导致更严重的后果。
所以在企业中,单播路由往往作为一种临时的解决方案,或者是仅仅用于测试。
三层交换机
可以简单的理解三层交换机就是二层交换机和路由器的合体
和单臂路由相比,三层交换机交换和路由模块是直接通过板载的总线进行通信的,而不是单臂路由里面的网线。
三层交换机由于性能和功能上都得到了兼顾,所以是更高性价比的选择,现在企业中,几乎都是三层交换机和二层交换机组网。
SVI(交换虚拟接口)
类似于单臂路由中的子接口,子接口并不是真实存在的,是一个逻辑上的接口。
![image-20200425140225045](/2020/04/25/san-ceng-jiao-huan/image-20200425140225045.png)
可以在路由模块中启动逻辑接口,逻辑接口的名字就是vlan号,逻辑接口会直接在交换模块中的对应VLAN中。
![image-20200425140442395](/2020/04/25/san-ceng-jiao-huan/image-20200425140442395.png)
Switch(config)#vlan 10,20
Switch(config-vlan)#int e0/2
Switch(config-if)#sw ac vl 10
Switch(config-if)#int e0/3
Switch(config-if)#sw ac vl 20
Switch(config-if)#int vl 10
Switch(config-if)#ip add 192.168.10.254 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#int vl 20
Switch(config-if)#ip add 192.168.20.254 255.255.255.0
Switch(config-if)#no sh
检查R2和R3的连通性
R2#ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 1/1/1 ms
三层交换机的路由模块可以和路由器一样启动任何协议
三层交换综合实验
![三层交换机](/2020/04/25/san-ceng-jiao-huan/%E4%B8%89%E5%B1%82%E4%BA%A4%E6%8D%A2%E6%9C%BA.png)
配置trunk
SW1(config)#int range e0/1 -2
SW1(config-if-range)#sw tr en do
SW1(config-if-range)#sw mo tr
=================================
SW2(config)#int range e0/1 -2
SW2(config-if-range)#sw tr en do
SW2(config-if-range)#sw mo tr
================================
SW3(config)#int range e0/1 -3, e1/1
SW3(config-if-range)#sw tr en do
SW3(config-if-range)#sw mo tr
================================
SW4(config)#int e0/2
SW4(config-if)#sw tr en do
SW4(config-if)#sw mo tr
================================
SW5(config)#int e0/1
SW5(config-if)#sw tr en do
SW5(config-if)#sw mo tr
配置vtp
SW3(config)#vtp do cisco
SW3(config)#vtp mo ser
==========================
除了Sw3外的交换机
vtp do cisco
vtp mo cl
创建vlan
SW3(config)#vlan 46,34,23,12,15,57
================================
去Sw3以外的交换机上检查是否同步vlan
show vlan
将R6R7对应接口加入vlan
SW4(config)#int e0/1
SW4(config-if)#sw ac vl 46
===================
SW5(config)#int e0/2
SW5(config-if)#sw ac vl 57
配置路由协议
R6(config)#int lo0
R6(config-if)#ip add 6.6.6.6 255.255.255.0
R6(config-if)#ip ospf 1 area 0
R6(config-if)#int e0/0
R6(config-if)#ip add 192.168.46.6 255.255.255.0
R6(config-if)#no sh
R6(config-if)#ip ospf 1 area 0
=====================================
SW4(config-if)#int vlan 46
SW4(config-if)#ip add 192.168.46.4 255.255.255.0
SW4(config-if)#no sh
SW4(config-if)#int lo0
SW4(config-if)#ip add 4.4.4.4 255.255.255.0
SW4(config-if)#int range lo0 , vl 46
SW4(config-if-range)#ip ospf 1 area 0
SW4(config-if-range)#int vl 34
SW4(config-if)#ip add 192.168.34.4 255.255.255.0
SW4(config-if)#no sh
SW4(config-if)#ip ospf 1 area 0
=======================================
SW3(config)#int lo0
SW3(config-if)#ip add 3.3.3.3 255.255.255.0
SW3(config-if)#no sh
SW3(config-if)#ip ospf 1 area 0
SW3(config-if)#int vlan 34
SW3(config-if)#ip add 192.168.34.3 255.255.255.0
SW3(config-if)#no sh
SW3(config-if)#ip ospf 1 area 0
SW3(config-if)#int vl 23
SW3(config-if)#ip add 192.168.23.3 255.255.255.0
SW3(config-if)#no sh
SW3(config-if)#ip ospf 1 area 1
============================================
SW2(config)#int lo0
SW2(config-if)#ip add 2.2.2.2 255.255.255.0
SW2(config-if)#ip ospf 1 area 1
SW2(config-if)#int vl 23
SW2(config-if)#ip add 192.168.23.2 255.255.255.0
SW2(config-if)#no sh
SW2(config-if)#ip ospf 1 area 1
SW2(config-if)#int vl 12
SW2(config-if)#ip add 192.168.12.2 255.255.255.0
SW2(config-if)#no sh
SW2(config-if)#router isis
SW2(config-router)#net 49.0001.0000.0000.0002.00
SW2(config-router)#is-type level-2
SW2(config-router)#int vl 12
SW2(config-if)#ip router isis
==============================================
SW1(config)#router isis
SW1(config-router)#net 49.0001.0000.0000.0001.00
SW1(config-router)#is-type level-2
SW1(config-router)#int lo0
SW1(config-if)#ip add 1.1.1.1 255.255.255.0
SW1(config-if)#ip router isis
SW1(config-if)#int vl 12
SW1(config-if)#ip add 192.168.12.1 255.255.255.0
SW1(config-if)#no sh
SW1(config-if)#ip router isis
SW1(config-if)#int vl 15
SW1(config-if)#ip add 192.168.15.1 255.255.255.0
SW1(config-if)#no sh
SW1(config-if)#router eigrp 100
SW1(config-router)#net 192.168.15.0
===============================================
SW5(config-if)#int lo0
SW5(config-if)#ip add 5.5.5.5 255.255.255.0
SW5(config-if)#int vl 15
SW5(config-if)#ip add 192.168.15.5 255.255.255.0
SW5(config-if)#no sh
SW5(config-if)#int vl 57
SW5(config-if)#ip add 192.168.57.5 255.255.255.0
SW5(config-if)#no sh
SW5(config-if)#router eigrp 100
SW5(config-router)#net 5.0.0.0
SW5(config-router)#net 192.168.15.0
SW5(config-router)#router rip
SW5(config-router)#ver 2
SW5(config-router)#no au
SW5(config-router)#net 192.168.57.0
==============================================
R7(config)#int lo0
R7(config-if)#ip add 7.7.7.7 255.255.255.0
R7(config-if)#int e0/1
R7(config-if)#ip add 192.168.57.7 255.255.255.0
R7(config-if)#no sh
R7(config-if)#router rip
R7(config-router)#ver 2
R7(config-router)#no au
R7(config-router)#net 7.0.0.0
R7(config-router)#net 192.168.57.0
检查路由协议邻居状态
检查OSPF
SW4#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 1 FULL/BDR 00:00:38 192.168.34.3 Vlan34
6.6.6.6 1 FULL/DR 00:00:39 192.168.46.6 Vlan46
======================================
SW3#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
4.4.4.4 1 FULL/DR 00:00:36 192.168.34.4 Vlan34
2.2.2.2 1 FULL/BDR 00:00:38 192.168.23.2 Vlan23
=====================================
R6#sh ip route ospf
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/13] via 192.168.46.4, 00:00:32, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/12] via 192.168.46.4, 00:00:32, Ethernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/11] via 192.168.46.4, 00:00:32, Ethernet0/0
O IA 192.168.23.0/24 [110/12] via 192.168.46.4, 00:00:32, Ethernet0/0
O 192.168.34.0/24 [110/11] via 192.168.46.4, 00:00:32, Ethernet0/0
检查ISIS
SW2#sh ip route isis
1.0.0.0/24 is subnetted, 1 subnets
i L2 1.1.1.0 [115/20] via 192.168.12.1, 00:05:36, Vlan12
检查eigrp
SW1#sh ip route eigrp
5.0.0.0/24 is subnetted, 1 subnets
D 5.5.5.0 [90/130816] via 192.168.15.5, 00:04:30, Vlan15
检查rip
SW5#sh ip route rip
7.0.0.0/24 is subnetted, 1 subnets
R 7.7.7.0 [120/1] via 192.168.57.7, 00:00:09, Vlan57
做双向重发布
SW2(config)#router ospf 1
SW2(config-router)#red isis level-2 subnets
SW2(config-router)#router isis
SW2(config-router)#redistribute ospf 1 level-2
==========================
SW1(config)#router isis
SW1(config-router)#redistribute eigrp 100 level-2
SW1(config-router)#router eigrp 100
SW1(config-router)#redistribute isis metric 10000 100 255 1 1500
==========================
SW5(config)#router rip
SW5(config-router)#redistribute eigrp 100 metric 5
SW5(config-router)#router eigrp 100
SW5(config-router)#redistribute rip metric 10000 100 255 1 1500
检查路由
R6#sh ip route ospf
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.46.4, 00:01:25, Ethernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/13] via 192.168.46.4, 00:04:45, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/12] via 192.168.46.4, 00:04:45, Ethernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/11] via 192.168.46.4, 00:04:45, Ethernet0/0
5.0.0.0/24 is subnetted, 1 subnets
O E2 5.5.5.0 [110/20] via 192.168.46.4, 00:01:01, Ethernet0/0
7.0.0.0/24 is subnetted, 1 subnets
O E2 7.7.7.0 [110/20] via 192.168.46.4, 00:00:19, Ethernet0/0
O E2 192.168.15.0/24 [110/20] via 192.168.46.4, 00:01:01, Ethernet0/0
O IA 192.168.23.0/24 [110/12] via 192.168.46.4, 00:04:45, Ethernet0/0
O 192.168.34.0/24 [110/11] via 192.168.46.4, 00:04:45, Ethernet0/0
O E2 192.168.57.0/24 [110/20] via 192.168.46.4, 00:00:19, Ethernet0/0
检查连通性和经过的路线
R6#ping 7.7.7.7
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/4 ms
R6#tr
R6#traceroute 7.7.7.7
Type escape sequence to abort.
Tracing the route to 7.7.7.7
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.46.4 1 msec 0 msec 0 msec
2 192.168.34.3 1 msec 1 msec 1 msec
3 192.168.23.2 2 msec 2 msec 2 msec
4 192.168.12.1 3 msec 2 msec 1 msec
5 192.168.15.5 2 msec 3 msec 2 msec
6 192.168.57.7 3 msec * 5 msec
思考一下,这个图中有没有环路,STP会不会阻塞,那流量还是这么走的么?
在Sw2的e0/2上抓包
![image-20200425145721589](/2020/04/25/san-ceng-jiao-huan/image-20200425145721589.png)