一、聚合
网关作为了一个广播域的中心出口;生成树的根网桥也是一棵树的中心,也是流量的集合点;
若将两者分配不同的设备将导致网络通讯资源浪费,故强烈建议两者在同一台汇聚层设备上;
若使用基于vlan或基于分组的STP协议来工作三层架构中,将导致vlan间或组间通讯时对汇聚层间链路带宽要求较高,可以通过 以太网通道 channel (cisco ) 以太网中继Eth-Trunk(华为) 技术来解决
通道技术将多个接口逻辑的整合为一个接口,实现带宽叠加的作用;
配置要求:
1、通道的对端必须为同一台设备;
2、通道的所有物理接口应该具有相同的速率、双工模式;相同的类型,相同的vlan允许列表;
三层通道:成为通道的所有物理链路必须先为三层接口;其意义在于将多个需要配置ip地址的接口逻辑为一个接口,配置一个ip地址即可
二、管理vlan;
二层交换机物理接口正常无法配置ip地址;故存在一个SVI(交换虚拟接口)接口;
该接口可以配置ip地址,出厂存在MAC地址;用于远程登录该设备;该接口默认在vlan1 中,故vlan1就被称为默认的管理vlan;
二层交换机仅存在一个svi,默认在vlan1中,转移到其他vlan时,之前的vlanif接口将自动被关闭;
三层交换机支持多个SVI接口,所有的svi可以共存;
[Huawei]interface Vlanif 2
[Huawei-Vlanif2]ip address 192.168.2.1 24
若其他网段设备需要访问svi,那么交换机必须定义网关地址,或缺省路由,否则无法回复;
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.2.254
三、三层交换机
普通的二层交换机具有三层路由器设备的功能;标准的3层交换机不具有nat功能;只能作为汇聚层设备,无法成为核心层连接互联网的设备;
默认情况下,cisco和华为的三层交换机所有物理接口为二层接口;
可以将三层交换机的接口修改为三层功能;
四、网关冗余
VRRP:虚拟路由冗余协议–公有协议,原理同HSRP一致
区别:1、多台设备 2、仅master发送hello 3、可以使用物理接口的ip地址来为网关地址 4、抢占默认开启 5、hold time 3s
VRRP在一个组内可以存在多台3层设备,存在一个master和多个backup
正常产生一个虚拟IP(可以为真实接口ip)和一个虚拟MAC
默认每1s来检测一次master是否活动 224.0.0.18 TTL=1 hold time 3s
选举规则:
先优先级,默认100,大优;再接口ip地址大优;
**特点:**切换速度快;可以使网关的IP和MAC地址不用变化;网关的切换对主机是透明的;
可以实施上行链路追踪
在网关冗余技术中,ICMP重定向是失效的;故当上行链路DOWN时,网关将不会切换;
可以定义上行链路追踪-----该配置必须在抢占开启的情况下生效,且两台设备间的优先级差值小于下调值; 若本地存在多条上行或下行链路,建议上行链路追踪配置时的下调值之和大于优先级差值----所有上行链路全down时,才让备份设备抢占;下行链路大部分down时,可以让备份设备抢占;
配置:
**注:**正常在三层架构中由于生成树的存在,负载分担方式将可能由于不同vlan根网桥位置不同,导致部分链路阻塞,使得负载分担反而成为累赘; 因此仅建议在直接使用路由器作为网关时,才使用负载分担方式;
实验要求:
实验拓扑:
实验步骤:
1、确定交换层的配置顺序:channel—> vlan—> Trunk----> STP---->SVI----->VRRP----->DHCP
2、绑定接口、创建vlan
[sw1]int Eth-Trunk 0
[sw1-GigabitEthernet0/0/1]eth-trunk 0
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]eth-trunk 0
[sw2]int Eth-Trunk 0
[sw2-GigabitEthernet0/0/1]eth-trunk 0
[sw2-GigabitEthernet0/0/1]int g0/0/2
[sw2-GigabitEthernet0/0/2]eth-trunk 0
设置接口类型:
[sw1]vlan 2
[sw1]port-group group-member GigabitEthernet 0/0/3 to g0/0/4 Eth-Trunk 0
[sw1-port-group]port link-type trunk
[sw1-GigabitEthernet0/0/3]port link-type trunk
[sw1-GigabitEthernet0/0/4]port link-type trunk
[sw1-Eth-Trunk0]port link-type trunk
[sw1-port-group]port trunk allow-pass vlan 1 2
[sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 1 2
[sw1-GigabitEthernet0/0/4]port trunk allow-pass vlan 1 2
[sw1-Eth-Trunk0]port trunk allow-pass vlan 1 2
[sw2]vlan 2
[sw2]port-group group-member GigabitEthernet 0/0/3 to g0/0/4 Eth-Trunk 0
[sw2-port-group]port link-type trunk
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/4]port link-type trunk
[sw2-Eth-Trunk0]port link-type trunk
[sw2-port-group]port trunk allow-pass vlan 1 2
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 1 2
[sw2-GigabitEthernet0/0/4]port trunk allow-pass vlan 1 2
[sw2-Eth-Trunk0]port trunk allow-pass vlan 1 2
[sw3]vlan 2
[sw3-Ethernet0/0/1]port link-type trunk
[sw3-Ethernet0/0/1]port trunk pvid vlan 2
[sw3-Ethernet0/0/2]port link-type trunk
[sw3-Ethernet0/0/2]port trunk allo-pass vlan 1 to 2
[sw3-Ethernet0/0/2]int e0/0/4
[sw3-Ethernet0/0/4]port link-type access
[sw3-Ethernet0/0/4]port default vlan 2
[sw4]vlan 2
[sw4-Ethernet0/0/1]port link-type trunk
[sw4-Ethernet0/0/1]port trunk pvid vlan 2
[sw4-Ethernet0/0/2]port link-type trunk
[sw4-Ethernet0/0/2]port trunk allo-pass vlan 1 to 2
[sw4-Ethernet0/0/2]int e0/0/4
[sw4-Ethernet0/0/4]port link-type access
[sw4-Ethernet0/0/4]port default vlan 2
配置MSTP
[sw1]stp mode mstp
[sw1]stp region-configuration
[sw1-mst-region]region-name a
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration
[sw2]stp mode mstp
[sw2]stp region-configuration
[sw2-mst-region]region-name a
[sw2-mst-region]instance 1 vlan 1
[sw2-mst-region]instance 2 vlan 2
[sw2-mst-region]active region-configuration
[sw3]stp mode mstp
[sw3]stp region-configuration
[sw3-mst-region]region-name a
[sw3-mst-region]instance 1 vlan 1
[sw3-mst-region]instance 2 vlan 2
[sw3-mst-region]active region-configuration
[sw4]stp mode mstp
[sw4]stp region-configuration
[sw4-mst-region]region-name a
[sw4-mst-region]instance 1 vlan 1
[sw4-mst-region]instance 2 vlan 2
[sw4-mst-region]active region-configuration
设置组根
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
设置边缘接口:
[sw3]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw3-port-group]stp edged-port enable
[sw3-Ethernet0/0/3]stp edged-port enable
[sw3-Ethernet0/0/4]stp edged-port enable
[sw4]port-group group-member Ethernet 0/0/3 to e0/0/4
[sw4-port-group]stp edged-port enable
[sw4-Ethernet0/0/3]stp edged-port enable
[sw4-Ethernet0/0/4]stp edged-port enable
配置根交换机并对其配置IP地址
[sw1-Vlanif1]dis this
#
interface Vlanif1
ip address 172.16.1.1 255.255.255.128
vrrp vrid 1 virtual-ip 172.16.1.126
vrrp vrid 1 priority 101
vrrp vrid 1 track interface GigabitEthernet0/0/5 reduced 2
[sw1-Vlanif1]int vlan 2
[sw1-Vlanif2]dis this
#
interface Vlanif2
ip address 172.16.1.129 255.255.255.128
vrrp vrid 1 virtual-ip 172.16.1.254
dhcp select global
#
return
[sw2-Vlanif1]dis this
#
interface Vlanif1
ip address 172.16.1.2 255.255.255.128
vrrp vrid 1 virtual-ip 172.16.1.126
#
return
[sw2-Vlanif1]int vlan 2
[sw2-Vlanif2]dis this
#
interface Vlanif2
ip address 172.16.1.130 255.255.255.128
vrrp vrid 1 virtual-ip 172.16.1.254
vrrp vrid 1 priority 101
vrrp vrid 1 track interface GigabitEthernet0/0/5
#
return
配置DHCP(在SW1和SW2 上进行配置)
DHCP enable
ip pool v1
gateway-list 172.16.1.126
network 172.16.1.0 mask 255.255.255.128
dns-list 114.114.114.114 8.8.8.8
ip pool v2
gateway-list 172.16.1.254
network 172.16.1.128 mask 255.255.255.128
dns-list 114.114.114.114 8.8.8.8
通过动态路由跑通内网:
[sw1-ospf-1]dis this
#
ospf 1 router-id 1.1.1.11
silent-interface all
undo silent-interface GigabitEthernet0/0/5
undo silent-interface Eth-Trunk0
undo silent-interface Vlanif1
undo silent-interface Vlanif99
area 0.0.0.0
network 172.16.0.2 0.0.0.0
area 0.0.0.1
abr-summary 172.16.1.0 255.255.255.0
network 172.16.1.1 0.0.0.0
network 172.16.1.129 0.0.0.0
#
return
[sw2-ospf-1]dis this
#
ospf 1 router-id 1.1.1.11
silent-interface all
undo silent-interface GigabitEthernet0/0/5
undo silent-interface Eth-Trunk0
undo silent-interface Vlanif1
undo silent-interface Vlanif99
area 0.0.0.0
network 172.16.0.6 0.0.0.0
area 0.0.0.1
abr-summary 172.16.1.0 255.255.255.0
network 172.16.1.2 0.0.0.0
network 172.16.1.130 0.0.0.0
#
return
[r1-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
#
return
[sw1]ip route-static 172.16.1.0 255.255.255.0 NULL 0
[sw2]ip route-static 172.16.1.0 255.255.255.0 NULL 0
配通外网:
[r1]ip route-static 0.0.0.0 0 12.1.1.2
[r1]ospf 1
[r1-ospf-1]default-route-advertise
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1-acl-basic-2000]int g0/0/2
[r1-GigabitEthernet0/0/2]nat outbound 2000
最后一步—测试:
测试四台PCping外网:
PC1
PC2
PC3
PC4