企業級網絡架構配置細則(壹)


 

企業網配置細則

實驗拓撲
在這里插入圖片描述

需求:

分流互備
  • 1

說明:

​ SW1、SW2是核心層與匯聚層的集合

為什么需要集合,為什么不是三層架構?
	匯聚層存在的意義是為核心分擔壓力,三層架構其實是核心層的性能不夠
  • 1
  • 2
各層的用途與意義
	接入層:提供端口的密度,用於用戶終端的接入—二層交換機、AP
	匯聚層(分布層):流量的集合,DHCP/VLAN/STP/HSRP/VRRP/channel…QOS/ACL
		為核心分擔壓力,三層架構其實是核心層的性能不夠
	核心層:nat、高速路由轉發

現在是二層架構(扁平化架構),不但性能提升了而且價格不貴
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

1、VLAN(Trunk、Access)

1.1 創建VLAN、修改接口模式

1、創建VLAN

四台交換機做創建VLAN方式相同

[SW1]vlan batch 2 3
  • 1

接入層交換機的下聯PC接口設置為access模式,其他口設置為trunk模式,華為還存在一種Hybrid模式,詳情請點擊

配置:

2、更改接口模式

​ 單個接口的更改:

port link-type access 
port link-type trunk
  • 1
  • 2

​ 多個接口的模式更改:

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

3、划入 VLAN

單個將接口划分到 vlan

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

批量將接口划分到 vlan2

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

1.3 鏈路聚合

過來的流量分布在聚合接口上,並不是簡單的帶寬疊加;

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

某些屬性,比如五元組(源目IP、源目MAC、協議等)
  • 1
[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

注意:

做鏈路聚合的負載分擔時,分擔流的內容越詳細,匹配越精確,分擔流量卻准確

鏈路聚合的接口分布在同一個板卡、不同板卡、不同設備;若要分布在不同的設備上時存在堆疊、虛擬化(將兩個設備合並為一個設備)、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做相同配置,注意聚合口有可能不一樣,本實驗一致
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

1.4 SW1 2間做出互聯地址

為什么需要互聯?
	1、匯聚層交換機的互聯鏈路是為了承載VLAN間通信,如果不存在的話VLAN間通信就會走接入層進行繞路,使接入層稱為中轉設備(匯聚層)

	2、當匯聚和核心上下連對角多條線路出現故障的時候,需要用到這條線路,防止繞路時使接入層成為匯聚層
  • 1
  • 2
  • 3
  • 4

配置

[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

查看

可見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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

查看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    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

測試驗證:

預期,主設備存在時,VLAN2 3 的PC獲取到的IP為2-128;當網關切換后,VLAN2 3 的PC獲取到的IP為129-253
在這里插入圖片描述在這里插入圖片描述

down掉SW1上聯的兩個接口,使VRRP進行網關的切換
在這里插入圖片描述在這里插入圖片描述

5、數據(上聯外網)

5.1 連接外網的接口

說明:真機上可以使用如下命令直接將二層接口改成三層的,但是模擬器不能這么敲,所以采用將接口划分進VLAN的情況來進行模擬

[SW1-GigabitEthernet0/0/5]undo portswitch 
  • 1

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
  • 1
  • 2
  • 3
  • 4
  • 5

外網回來(進)

[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

注意:由於存在兩個外網,即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
  • 1
  • 2

6、測試

6.1 VLAN2的網關切換

斷掉SW1的一條上行鏈路,注意這里也要斷掉VLAN11,要不默認缺省走的還是R1上去,可見,斷掉一條上行並不會切換網關
在這里插入圖片描述

PC1pingR1的環回

在這里插入圖片描述

斷掉SW1的所有上聯,此時不用斷掉vlan,因為網關已經被VRRP切換了
在這里插入圖片描述在這里插入圖片描述

6.2 VLAN3的網關切換

斷掉SW2的一條上行鏈路,注意這里也要斷掉VLAN11,要不默認缺省走的還是R1上去,可見,斷掉一條上行並不會切換網關
在這里插入圖片描述
PC7pingR2的環回
在這里插入圖片描述

斷掉SW2的所有上聯,此時不用斷掉vlan,因為網關已經被VRRP切換了
在這里插入圖片描述在這里插入圖片描述
當上行鏈路正常時,即正常情況下的走法如下
在這里插入圖片描述
測試完成,與預期相符


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM