文章目录

 

企业网配置细则

实验拓扑

公司小型网络架构 公司网络架构与配置_链路

需求:

分流互备

说明:

SW1、SW2是核心层与汇聚层的集合

为什么需要集合,为什么不是三层架构?
	汇聚层存在的意义是为核心分担压力,三层架构其实是核心层的性能不够
各层的用途与意义
	接入层:提供端口的密度,用于用户终端的接入—二层交换机、AP
	汇聚层(分布层):流量的集合,DHCP/VLAN/STP/HSRP/VRRP/channel…QOS/ACL
		为核心分担压力,三层架构其实是核心层的性能不够
	核心层:nat、高速路由转发

现在是二层架构(扁平化架构),不但性能提升了而且价格不贵

1、VLAN(Trunk、Access)

1.1 创建VLAN、修改接口模式

1、创建VLAN

四台交换机做创建VLAN方式相同

[SW1]vlan batch 2 3


接入层交换机的下联PC接口设置为access模式,其他口设置为trunk模式,华为还存在一种Hybrid模式,详情请点击

配置:

2、更改接口模式

单个接口的更改:

port link-type access 
port link-type trunk

多个接口的模式更改:

[Huawei]port-group 1
[Huawei]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/10
[Huawei]port link-type access

3、划入 VLAN

单个将接口划分到 vlan

[SWA]interface GigabitEthernet0/0/5
[SWA-GigabitEthernet0/0/5]port default vlan 3

批量将接口划分到 vlan2

[Huawei]vlan 2
[Huawei-vlan2]port GigabitEthernet 0/0/1 to 0/0/2

1.3 链路聚合

过来的流量分布在聚合接口上,并不是简单的带宽叠加;

按照流分布,而不是包分布;一个流只能被分布在一个物理接口上的

某些属性,比如五元组(源目IP、源目MAC、协议等)
[SW1-Eth-Trunk1]load-balance ?
  dst-ip       According to destination IP hash arithmetic
  dst-mac      According to destination MAC hash arithmetic
  src-dst-ip   According to source/destination IP hash arithmetic
  src-dst-mac  According to source/destination MAC hash arithmetic
  src-ip       According to source IP hash arithmetic
  src-mac      According to source MAC hash arithmetic

注意:

做链路聚合的负载分担时,分担流的内容越详细,匹配越精确,分担流量却准确

链路聚合的接口分布在同一个板卡、不同板卡、不同设备;若要分布在不同的设备上时存在堆叠、虚拟化(将两个设备合并为一个设备)、M-LAG

配置:

[SW1-Eth-Trunk1]di th
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 2 to 4094
#
return
[SW1-Eth-Trunk1]trunkport GigabitEthernet 0/0/2
[SW1-Eth-Trunk1]trunkport GigabitEthernet 0/0/3
查看:
[SW1-GigabitEthernet0/0/2]di th
#
interface GigabitEthernet0/0/2
 eth-trunk 1
#
return
[SW1-GigabitEthernet0/0/3]di th
#
interface GigabitEthernet0/0/3
 eth-trunk 1
#
return

SW2做相同配置,注意聚合口有可能不一样,本实验一致
  • 24

1.4 SW1 2间做出互联地址

为什么需要互联?
	1、汇聚层交换机的互联链路是为了承载VLAN间通信,如果不存在的话VLAN间通信就会走接入层进行绕路,使接入层称为中转设备(汇聚层)

	2、当汇聚和核心上下连对角多条线路出现故障的时候,需要用到这条线路,防止绕路时使接入层成为汇聚层

配置

[SW1-Vlanif102]di th
#
interface Vlanif102
 ip address 10.2.102.1 255.255.255.0
#
return

[SW2-Vlanif102]di th
#
interface Vlanif102
 ip address 10.2.102.2 255.255.255.0
#
return

2、MSTP(生成树)

2.1MST域

配置,为保证所有的交换机都在同一个MST域内,则name、level、instance配置都需相同,即以下配置都需相同

[SW1-mst-region]di th
#
stp region-configuration
 region-name hw
 revision-level 1
 instance 1 vlan 2
 instance 2 vlan 3
 active region-configuration
#
return

2.2 Master/Backup

主备分流,即使SW1作为实例1的主根,VLAN2是属于实例1的

两种配置方式:
第一种 直接对实例进行根的主备配置
[SW1]stp instance 1 root primary 
[SW2]stp instance 1 root secondary 
第二种 采用优先级的方式对实例进行根的主备配置
[SW1]stp instance 1 priority 0
[SW2]stp instance 1 priority 4096

查看

可见SW1就是实例1的主根,根桥是自己,优先级为最高0;是实例2的备根
[SW1]dis stp instance 1
-------[MSTI 1 Global Info]-------
MSTI Bridge ID      :0.4c1f-cc65-7998
MSTI RegRoot/IRPC   :0.4c1f-cc65-7998 / 0
MSTI RootPortId     :0.0
Master Bridge       :32768.4c1f-cc65-7998
[SW1]dis stp instance 2
-------[MSTI 2 Global Info]-------
MSTI Bridge ID      :4096.4c1f-cc65-7998
MSTI RegRoot/IRPC   :0.4c1f-ccfc-4e13 / 10000
MSTI RootPortId     :128.25
Master Bridge       :32768.4c1f-cc65-7998

SW2同理
[SW2]dis stp instance 2
-------[MSTI 2 Global Info]-------
MSTI Bridge ID      :0.4c1f-ccfc-4e13
MSTI RegRoot/IRPC   :0.4c1f-ccfc-4e13 / 0
MSTI RootPortId     :0.0
Master Bridge       :32768.4c1f-cc65-7998
[SW2]dis stp instance 1
-------[MSTI 1 Global Info]-------
MSTI Bridge ID      :4096.4c1f-ccfc-4e13
MSTI RegRoot/IRPC   :0.4c1f-cc65-7998 / 10000
MSTI RootPortId     :128.25
Master Bridge       :32768.4c1f-cc65-7998

3、VRRP(热备份网关)

为什么需要?

1、设备的死机

2、下联与互联交换机的接口down

3、上联接口down

如果做的是OSPF则需要VRRP的条件唯一是设备的down

上行链路追踪:

增加优先级使用情况:

当做割接时,需要在短时间内将主网关切换到新网关上;当上行链路一旦启动,优先级增加,则实现切换。 优先级越大越优

抢占是抢占回来的时候,而不是丢掉失去的时候

说明:

由于上联有两个路由器,若需对上联链路做跟踪的话,需要监控两端链路,每段链路减小15,即只有当两端链路都出现故障后,主网关的优先级才会减小的比备网关的小,实现切换

为了防止终端的伪造数据对VRRP产生影响干扰,则再VRRP中做出认证

配置:

VLAN2的VRRP(SW1为主)

[SW1-Vlanif2]di th
#
interface Vlanif2
 ip address 10.2.2.1 255.255.255.0
 vrrp vrid 1 virtual-ip 10.2.2.254
 vrrp vrid 1 priority 120
 vrrp vrid 1 preempt-mode timer delay 5
 vrrp vrid 1 track interface GigabitEthernet0/0/5 reduced 15
 vrrp vrid 1 track interface GigabitEthernet0/0/6 reduced 15
 vrrp vrid 1 authentication-mode md5 h!1I8"-zqX$+cx#k/mS=SrB#
#
return

[SW2-Vlanif2]di th
#
interface Vlanif2
 ip address 10.2.2.2 255.255.255.0
 vrrp vrid 1 virtual-ip 10.2.2.254
 vrrp vrid 1 priority 101
 vrrp vrid 1 authentication-mode md5 FLAzLNtpS!Wq<}.DH-])vrr#
#
return

VLAN3的VRRP(SW1为主)

[SW2-Vlanif3]di th
#
interface Vlanif3
 ip address 10.2.3.1 255.255.255.0
 vrrp vrid 1 virtual-ip 10.2.3.254
 vrrp vrid 1 priority 120
 vrrp vrid 1 track interface GigabitEthernet0/0/5 reduced 15
 vrrp vrid 1 track interface GigabitEthernet0/0/6 reduced 15
 vrrp vrid 1 authentication-mode md5 :EQX>]u(&E:.`&R&e7S(fJ)#
 dhcp select global
#
return

[SW1-Vlanif3]di th
#
interface Vlanif3
 ip address 10.2.3.2 255.255.255.0
 vrrp vrid 1 virtual-ip 10.2.3.254
 vrrp vrid 1 priority 101
 vrrp vrid 1 authentication-mode md5 e2VJ&)RP"!Hj<w)JO!C@&H##
#
return

查看VRRP的状态

[SW1]dis vrrp brief 
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Master       Vlanif2                  Normal   10.2.2.254     
1     Backup       Vlanif3                  Normal   10.2.3.254     
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0 

[SW2]dis vrrp brief 
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Master       Vlanif3                  Normal   10.2.3.254     
1     Backup       Vlanif2                  Normal   10.2.2.254     
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0

4.DHCP

分析说明:

由于本实验中存在VRRP,即网关的备份,那么当网关切换后,DHCP也就失效,那么就需要两个DHCP池塘;存在以下两种配置方案

1、两边同时配,池子切半(使用去除地址的方式)

2、使用中继,即使用一个DHCP服务器,交换机就是一个中继设备

采用方案一

将SW1上的DHCP池塘地址设置为1-128

将SW2上的DHCP池塘地址设置为129-253

全局模式下 dhcp enable
进入vlan2 dhcp select global
[SW1-ip-pool-vlan2]di th
#
ip pool vlan2
 gateway-list 10.2.2.254
 network 10.2.2.0 mask 255.255.255.0
 excluded-ip-address 10.2.2.129 10.2.2.253  去掉的地址,即主网关存在时,DHCP分配的地址为除了129-253的地址
 dns-list 114.114.114.114
#
return
[SW2-ip-pool-vlan2]di th
#
ip pool vlan2
 gateway-list 10.2.2.254
 network 10.2.2.0 mask 255.255.255.0
 excluded-ip-address 10.2.2.1 10.2.2.128 去掉的地址,即网关切换后,备设备上DHCP分配的地址为除了1-128的地址
 dns-list 114.114.114.114
#
return


VLAN3地址池的配置类似,如下所示
[SW2-ip-pool-vlan3]di th
#
ip pool vlan3
 gateway-list 10.2.3.254
 network 10.2.3.0 mask 255.255.255.0
 excluded-ip-address 10.2.3.129 10.2.3.253
 dns-list 114.114.114.114
#
return
[SW1-ip-pool-vlan3]di th
#
ip pool vlan3
 gateway-list 10.2.3.254
 network 10.2.3.0 mask 255.255.255.0
 excluded-ip-address 10.2.3.1 10.2.3.128
 dns-list 114.114.114.114
#
return

测试验证:

预期,主设备存在时,VLAN2 3 的PC获取到的IP为2-128;当网关切换后,VLAN2 3 的PC获取到的IP为129-253

公司小型网络架构 公司网络架构与配置_链路_02

公司小型网络架构 公司网络架构与配置_公司小型网络架构_03

down掉SW1上联的两个接口,使VRRP进行网关的切换

公司小型网络架构 公司网络架构与配置_DHCP_04

公司小型网络架构 公司网络架构与配置_链路_05

5、数据(上联外网)

5.1 连接外网的接口

说明:真机上可以使用如下命令直接将二层接口改成三层的,但是模拟器不能这么敲,所以采用将接口划分进VLAN的情况来进行模拟

[SW1-GigabitEthernet0/0/5]undo portswitch

5.2 路由

去外网(出)

[SW1]ip route-static 0.0.0.0 0 10.2.11.1 
[SW1]ip route-static 0.0.0.0 0 10.2.12.1 preference 100

[SW2]ip route-static 0.0.0.0 0 10.2.22.1 
[SW2]ip route-static 0.0.0.0 0 10.2.21.1 preference 100

外网回来(进)

[R1]ip route-static 10.2.2.0 24 10.2.11.2 
[R1]ip route-static 10.2.2.0 24 10.2.21.2 preference 100
[R1]ip route-static 10.2.3.0 24 10.2.21.2 
[R1]ip route-static 10.2.3.0 24 10.2.11.2 preference 100

[R2]ip route-static 10.2.2.0 24 10.2.12.2 
[R2]ip route-static 10.2.2.0 24 10.2.22.2 preference 100
[R2]ip route-static 10.2.3.0 24 10.2.22.2 
[R2]ip route-static 10.2.3.0 24 10.2.12.2 preference 100

注意:由于存在两个外网,即R1、R2,可以理解为两个运营商,即电信、联通;所以两个运营商之间是需要有路由的;由于这里写的是静态,所以路由会比较多,后期直接用OSPF一跑直接完事

由于测试使用的是R1 R2的环回,其二者本身也需要通,即写两条静态

[R1]ip route-static 2.2.2.0 24 10.2.201.2
[R2]ip route-static 1.1.1.0 24 10.2.201.1

6、测试

6.1 VLAN2的网关切换

断掉SW1的一条上行链路,注意这里也要断掉VLAN11,要不默认缺省走的还是R1上去,可见,断掉一条上行并不会切换网关

公司小型网络架构 公司网络架构与配置_IP_06

PC1pingR1的环回

公司小型网络架构 公司网络架构与配置_链路_07

断掉SW1的所有上联,此时不用断掉vlan,因为网关已经被VRRP切换了

公司小型网络架构 公司网络架构与配置_公司小型网络架构_08

公司小型网络架构 公司网络架构与配置_IP_09

6.2 VLAN3的网关切换

断掉SW2的一条上行链路,注意这里也要断掉VLAN11,要不默认缺省走的还是R1上去,可见,断掉一条上行并不会切换网关

公司小型网络架构 公司网络架构与配置_公司小型网络架构_10


PC7pingR2的环回

公司小型网络架构 公司网络架构与配置_IP_11

断掉SW2的所有上联,此时不用断掉vlan,因为网关已经被VRRP切换了

公司小型网络架构 公司网络架构与配置_IP_12

公司小型网络架构 公司网络架构与配置_链路_13


当上行链路正常时,即正常情况下的走法如下

公司小型网络架构 公司网络架构与配置_DHCP_14


测试完成,与预期相符