不同Vlan在三层交换机上实现路由


如何在三层设备上怎么配置vlan间的路由?这是很多工程师经常遇到的问题。其实vlan间的路由有两种:单臂路由和三层交换路由。下面具体写一下三层之间的路由。

实验拓扑如下图一个三层核心交换机,两个二层交换机。

1、设置VTP domain

在S1上启用sever模式,S2和S3启用client模式

S1>en

S1#configure terminal

S1(config)#vtp domain cisco

S1(config)#vtp mode server

S2>en

S2#configure terminal

S2(config)#vtp domain cisco

S2(config)#vtp mode client

S3>en

S3#configure terminal

S3(config)#vtp domain cisco

S3(config)#vtp mode client

2、配置中继为了保证管理域能够覆盖所有的分支交换机,必须配置中继。

这里只需要在S1上的f0/1和f0/2口起trunk就可以了

S1(config)#interface range f0/1-f0/2

S1(config-if-range)#switchport trunk encapsulation dot1q

S1(config-if-range)#switchport mode trunk

3、创建Vlan

在S2上的vlan表如下:

S2#show vlan br

4、将交换机接口纳入Vlan

S2(config)#interface fastEthernet 0/2

S2(config-if)#switchport access vlan 10

S3(config)#interface fastEthernet 0/2

S3(config-if)#switchport access vlan 20

5、配置三层交换

给每个Vlan配IP地址

S1(config)#interface vlan 10

S1(config-if)#ip add 192.168.1.254 255.255.255.0

S1(config)#interface vlan 20

S1(config-if)#ip add 192.168.2.254 255.255.255.0

启用路由模式

S1(config)#ip routing

由于拓扑是直连路由这里不用做宣告

Gateway of last resort is not set

C 192.168.1.0/24 is directly connected, Vlan10

C 192.168.2.0/24 is directly connected, Vlan20

在客户端坐下测试

OK实验成功,看来学到的知识是忘不掉的。

相关内容