目录
一、基础知识
三层路由引擎是可以关闭或开启的
三层交换机的优点 与单臂路由相比
三层交换机上起虚接口(配置VLAN的网关)
二层端口升级为三层端口
二、实验过程
拓扑图
2.1 交换部分
1)Trunk
2)VTP & 创建vlan
3)分配端口到vlan
4)起三层交换机的虚接口
5)以三层交换机作为DHCP服务器
2.2 路由部分
1)配置IP并开启
2)配置路由
三层交换机 = 三层路由+二层交换机
conf t
ip routing 开启三层路由功能
no ip routing 关闭三层路由功能
int vlan 10
ip add 10.1.1.254 255.255.255.0
no shut
exit
int f0/x
no switchport
ip add ...
no shut
Switch(config)#ho sw1
sw1(config)#int f0/2
sw1(config-if)#sw m t
Switch(config)#ho sw2
sw2(config)#int f0/3
sw2(config-if)#sw m t
Switch(config)#ho sw0
sw0(config)#int range f0/2 - 3
sw0(config-if-range)#switchport trunk encapsulation dot1q (注释:指定封装类型)
sw0(config-if-range)#sw m t
sw0(config-if-range)#exit
sw0(config)#vtp domain wencoll
Changing VTP domain name from NULL to wencoll
sw0(config)#vlan 10
sw0(config-vlan)#exit
sw0(config)#vlan 20
sw0(config-vlan)#exit
sw1(config)#int f0/1
sw1(config-if)#sw ac vlan 10
sw1(config-if)#exit
sw2(config)#int f0/1
sw2(config-if)#sw ac vlan 20
sw2(config-if)#exit
sw0(config)#ip routing (注:开启三层路由功能)
sw0(config)#int vlan 10
sw0(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
sw0(config-if)#ip add 10.1.1.254 255.255.255.0
sw0(config-if)#no sh
sw0(config-if)#exit
sw0(config)#int vlan 20
sw0(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
sw0(config-if)#ip add 20.1.1.254 255.255.255.0
sw0(config-if)#no sh
sw0(config-if)#exit
sw0(config)#ip dhcp excluded-address 10.1.1.1 10.1.1.99
sw0(config)#ip dhcp pool v10
sw0(dhcp-config)#network 10.1.1.0 255.255.255.0
sw0(dhcp-config)#default-router 10.1.1.254
sw0(dhcp-config)#exit
sw0(config)#ip dhcp excluded-address 20.1.1.1 20.1.1.99
sw0(config)#ip dhcp pool v20
sw0(dhcp-config)#network 20.1.1.0 255.255.255.0
sw0(dhcp-config)#default-router 20.1.1.254
sw0(dhcp-config)#exit
阶段性小成功~
sw0(config)#int f0/1
sw0(config-if)#no sw (注:二层端口升级为三层端口)
sw0(config-if)#ip add 30.1.1.1 255.255.255.0
sw0(config-if)#no shut
sw0(config-if)#exit
Router(config)#ho R1
R1(config)#int f0/1
R1(config-if)#ip add 30.1.1.2 255.255.255.0
R1(config-if)#no shut
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#exit
R1(config)#int f0/0
R1(config-if)#ip add 40.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
R1(config-if)#exit
Router(config)#ho R2
R2(config)#int f0/0
R2(config-if)#ip add 40.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#exit
R2(config)#int f0/1
R2(config-if)#ip add 40.1.1.254 255.255.255.0
% 40.1.1.0 overlaps with FastEthernet0/0
R2(config-if)#ip add 50.1.1.254 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config-if)#exit
sw0:向外网指一条默认路由
sw0(config)#ip route 0.0.0.0 0.0.0.0 30.1.1.2
R2:向内网指一条默认路由
R2(config)#ip route 0.0.0.0 0.0.0.0 40.1.1.1
R1:
R1(config)#ip route 50.1.1.0 255.255.255.0 40.1.1.2
R1(config)#ip route 10.1.1.0 255.255.255.0 30.1.1.1
R1(config)#ip route 20.1.1.0 255.255.255.0 30.1.1.1
现在!全网互通!!!
PC1可以ping通PC3