三层交换机
SVI功能(交换机虚拟接口)
-
实现VLAN路由
-
需求 :各实训室使用独立局域网,即每个实训有自己的IP网段, 每个实训室只有内部互相访问。
-
需求:为了加强各实训室学生的交流,学校要求我们将各实训室电脑网络连接起来。
-
1. 先去汇聚层划分VLAN,
-
2. 把实训一划分到VLAN10,
-
3. 把实训二划分到VLAN20
-
4. 让汇聚层连接核心层的端口模式修改为trunk
三层交换机(s3560)
-
1. 在核心层划分和汇聚层相同个数的VLAN
-
vlan 10
-
exit
-
-
2. 先将该接口的Trunk封装为802.1Q的帧格式
-
switchport trunk encapsulation dotlq
-
-
3. 将三层交换机的端口设为trunk模式
-
switchport mode trunk
-
-
4. 进入SVI模式 (vlan 10 只是进入)
-
interface vlan 10
-
-
5. 设IP网关
-
ip address 192.168.10.254 255.255.255.0
-
-
6. 开启
-
no shutdown
-
-
7. 开启路由功能,才能跨网络(全局模式)
-
ip routing
-
具体步骤
先在二层交换机(汇聚层)
Switch>enable //进入特权
Switch#configure terminal //进入全局
Switch(config)#vlan 10 // 划分VLAN
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#interface f0/5 // 进入f0/5端口
Switch(config-if)#switchport access vlan 10 //设置端口模式为access ,把这个端口添加到VLAN10
Switch(config-if)#exit
Switch(config)#interface f0/10 // 进入f0/10端口
Switch(config-if)#switchport access vlan 20 //设置端口模式为access ,把这个端口添加到VLAN10
Switch(config-if)#exit
// 汇聚层和核心层连接的端口一定要设为trunk模式,要和三层一致
Switch(config)#interface f0/24 // 进入f0/24端口
Switch(config-if)#switchport mode trunk //修改端口模式为trunk
三层交换机(核心层)
-
选no
% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]: no
Switch>enable //进入特权
Switch#configure terminal //进入全局
Switch(config)#interface f0/24 //进入f0/24端口
Switch(config-if)#switchport trunk encapsulation dot1q//先将该接口的Trunk封装为802.1Q的帧格式
Switch(config-if)#switchport mode trunk //再配置端口模式为Trunk
Switch(config-if)#exit
Switch(config)#vlan 10 //创建VLAN
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#interface vlan 10 进入SVI
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
配置该SVI接口的IP地址,作为所在VLAN主机的网关
Switch(config-if)#ip address 192.168.10.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#interface vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#ip address 192.168.20.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#ip routing //开启路由功能,才能跨网络