雙防火牆+雙核心交換機,故障自動切換的配置方法

2022-03-24     IT狂人日誌

原標題:雙防火牆+雙核心交換機,故障自動切換的配置方法

上一篇文章中,我們講述了雙防火牆的基礎配置,也就是利用心跳線配置防火牆的HRP,發生故障的時候,自動切換。

由於核心交換機還沒配置完成,所以也不便測試,今天這篇文章會完結,所以後面會有故障測試的截圖。

照顧到沒看上一篇文章的讀者,還是要把拓撲圖貼一下,便於文章的閱讀。

重申一下,上圖中,AR1代表運營商雙出口網絡,事實上並不存在這台設備;並且,銀行也並沒有採用PPPOE鏈路,只是為了順便展示一下PPPOE的配置而已。

兩台華為的防火牆,fw1為主,fw2為備;兩台華為核心交換機,沒有採用堆疊技術,而是採用VRRP技術進行配置。

一、核心交換機的基礎配置

[SW1]int Eth-Trunk 12

[SW1-Eth-Trunk12]mode lacp-static //兩台核心交換機配置eth-trunk,並且設定聚合模式

[SW1-Eth-Trunk12]trunkport GigabitEthernet 0/0/2 to 0/0/3

[SW1-Eth-Trunk12]q

[SW1]vlan batch 10 20 100 //創建VLAN

[SW1]port-group group-member Eth-Trunk 12 GigabitEthernet 0/0/1 g0/0/4 g0/0/5

[SW1-port-group]p l t //網絡設備之間的連接接口配置為trunk模式

[SW1-port-group]p t a v a //允許所有VLAN通過

[SW1-port-group]quit

[SW1]int g0/0/6

[SW1-GigabitEthernet0/0/6]p l a //6口和7口配置為access模式,並且劃在VLAN100內

[SW1-GigabitEthernet0/0/6]p d v 100

[SW1-GigabitEthernet0/0/6]q

[SW1]int g0/0/7

[SW1-GigabitEthernet0/0/7]p l a

[SW1-GigabitEthernet0/0/7]p d v 100

[SW1-GigabitEthernet0/0/7]q

核心2的配置,基本上差不多,就不再重複了,下面兩台接入層的交換機,也很簡單

二、接入交換機的基礎配置

[SW3]vlan batch 10 20 100

[SW3]port-group group-member e0/0/1 e0/0/2

[SW3-port-group]p l t

[SW3-port-group]p t a v a

[SW3-port-group]q

[SW3]int e0/0/3

[SW3-Ethernet0/0/3]p l a

[SW3-Ethernet0/0/3]p d v 10

[SW3-Ethernet0/0/3]q

[SW4]vlan batch 10 20 100

[SW4]port-group group-member e0/0/1 e0/0/2

[SW4-port-group]p l t

[SW4-port-group]p t a v a

[SW4-port-group]q

[SW4]port-group group-member e0/0/3 e0/0/4

[SW4-port-group]p l a

[SW4-port-group]p d v 20

[SW4-port-group]q

三、交換機配置MSTP和VRRP

[SW1]stp mode mstp //切換為mstp模式,應該是默認值,穩妥起見,還是輸入一遍吧

[SW1]stp region-configuration

[SW1-mst-region]region-name huawei

[SW1-mst-region]revision-level 1

[SW1-mst-region]instance 1 vlan 10 100 //sw1主要跑vlan10和vlan100的數據流量

[SW1-mst-region]instance 2 vlan 20

[SW1-mst-region]ac region-configuration

[SW1-mst-region]quit

[SW1]stp instance 1 root primary

[SW1]stp instance 2 root secondary

[SW1]int g0/0/6 //6和7接口是連接電腦和伺服器,所以設置為邊緣埠,加快STP收斂

[SW1-GigabitEthernet0/0/6]stp edged-port enable

[SW1-GigabitEthernet0/0/6]int g0/0/7

[SW1-GigabitEthernet0/0/7]stp edged-port enable

[SW1-GigabitEthernet0/0/7]q

MSTP配完了,緊接著配置VRRP

[SW1]int vlan 10

[SW1-Vlanif10]ip add 192.168.10.1 24

[SW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254

[SW1-Vlanif10]vrrp vrid 1 priority 120

[SW1-Vlanif10]quit

[SW1]int vlan 20

[SW1-Vlanif20]ip add 192.168.20.1 24

[SW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254

[SW1-Vlanif20]q

繼續配置DHCP Server

[SW1]dhcp enable

[SW1]ip pool VLAN10

[SW1-ip-pool-vlan10]network 192.168.10.0 mask 24

[SW1-ip-pool-vlan10]excluded-ip-address 192.168.10.1 192.168.10.10

[SW1-ip-pool-vlan10]gateway-list 192.168.10.254

[SW1-ip-pool-vlan10]dns-list 114.114.114.114

[SW1-ip-pool-vlan10]q

[SW1]int Vlanif 10

[SW1-Vlanif10]dhcp select global

[SW1-Vlanif10]q

[SW1]ip pool VLAN20

[SW1-ip-pool-vlan20]network 192.168.20.0 mask 24

[SW1-ip-pool-vlan20]excluded-ip-address 192.168.20.1 192.168.20.10

[SW1-ip-pool-vlan20]gateway-list 192.168.20.254

[SW1-ip-pool-vlan20]dns-list 114.114.114.114

[SW1-ip-pool-vlan20]q

[SW1]int vlan 20

[SW1-Vlanif20]dhcp select global

[SW1-Vlanif20]q

[SW2]stp region-configuration

[SW2-mst-region] region-name huawei

[SW2-mst-region] revision-level 1

[SW2-mst-region] instance 1 vlan 10 100

[SW2-mst-region] instance 2 vlan 20

[SW2-mst-region] active region-configuration

[SW2]stp instance 1 root secondary

[SW2]stp instance 2 root primary //sw2主要跑vlan20的數據流量

[SW2]int vlan 10

[SW2-Vlanif10]ip address 192.168.10.2 24

[SW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254

[SW2-Vlanif10]q

[SW2]int vlan 20

[SW2-Vlanif20]ip address 192.168.20.2 24

[SW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254

[SW2-Vlanif20]vrrp vrid 2 priority 120

[SW2-Vlanif20]q

[SW2]ip pool vlan10

[SW2-ip-pool-vlan10] gateway-list 192.168.10.254

[SW2-ip-pool-vlan10] network 192.168.10.0 mask 255.255.255.0

[SW2-ip-pool-vlan10] excluded-ip-address 192.168.10.1 192.168.10.10

[SW2-ip-pool-vlan10] dns-list 114.114.114.114

[SW2]ip pool vlan20

[SW2-ip-pool-vlan20] gateway-list 192.168.20.254

[SW2-ip-pool-vlan20] network 192.168.20.0 mask 255.255.255.0

[SW2-ip-pool-vlan20] excluded-ip-address 192.168.20.1 192.168.20.10

[SW2-ip-pool-vlan20] dns-list 114.114.114.114

[SW2-ip-pool-vlan20]q

[SW2]dhcp enable

[SW2]int vlan 10

[SW2-Vlanif10]dhcp se gl

[SW2-Vlanif10]q

[SW2]int vlan 20

[SW2-Vlanif20]dhcp se gl

[SW2-Vlanif20]q

兩台核心交換機上都配置了DHCP,你們猜會不會有地址池衝突?會不會有DHCP服務衝突?

不僅是兩台核心,下面的接入層交換機,也要做相應的配置

[SW3]stp region-configuration

[SW3-mst-region] region-name huawei

[SW3-mst-region] revision-level 1

[SW3-mst-region] instance 1 vlan 10 100

[SW3-mst-region] instance 2 vlan 20

[SW3-mst-region] active region-configuration

[SW3]int e0/0/3

[SW3-Ethernet0/0/3]stp ed enable

[SW3-Ethernet0/0/3]q

[SW4]stp region-configuration

[SW4-mst-region] region-name huawei

[SW4-mst-region] revision-level 1

[SW4-mst-region] instance 1 vlan 10 100

[SW4-mst-region] instance 2 vlan 20

[SW4-mst-region] active region-configuration

[SW4]int e0/0/3

[SW4-Ethernet0/0/3]stp edged-port enable

[SW4-Ethernet0/0/3]q

[SW4]int e0/0/4

[SW4-Ethernet0/0/4]stp edged-port enable

[SW4-Ethernet0/0/4]q

一頓操作猛如虎,PC拿到IP;

四、與防火牆對接的配置:

[SW1]vlan 111

[SW1-vlan111]q

[SW1]int Vlanif 111

[SW1-Vlanif111]ip add 172.16.111.1 24

[SW1-Vlanif111]quit

[SW1]ospf router-id 172.1.1.1

[SW1-ospf-1]area 0

[SW1-ospf-1-area-0.0.0.0]net 192.168.10.1 0.0.0.0

[SW1-ospf-1-area-0.0.0.0]net 192.168.20.1 0.0.0.0

[SW1-ospf-1-area-0.0.0.0]net 172.16.111.1 0.0.0.0

[SW1-ospf-1-area-0.0.0.0]q

[SW2]vlan 112

[SW2-vlan112]q

[SW2]int vlan 112

[SW2-Vlanif112]ip add 172.16.112.2 24

[SW2-Vlanif112]q

[SW2]ospf router-id 172.16.112.2

[SW2-ospf-1]area 0

[SW2-ospf-1-area-0.0.0.0]network 192.168.10.2 0.0.0.0

[SW2-ospf-1-area-0.0.0.0]network 192.168.20.2 0.0.0.0

[SW2-ospf-1-area-0.0.0.0]net 172.16.112.2 0.0.0.0

[SW2-ospf-1-area-0.0.0.0]q

上一篇文章中,兩台防火牆也配置了OSPF,現在OSPF能跑起來了:

這時候,PC1和PC2是無法訪問PC3和Server1的,因為PC3和Server1在VLAN10裡面,而VLAN10的網關是防火牆的VRRP IP,有些人會問,VLAN10的網關為什麼不放在交換機的VRRP上呢?

因為,伺服器更需要安全防護,所以訪問伺服器必須經過防火牆先生的同意和監管,嘿嘿。

所以,我們需要配置相應的安全策略才行。

security-policy

rule name in2server //創建安全策略,名稱自己知道意義就行

source-zone trust //源安全區域:trust

destination-zone dmz //目的安全區域:dmz

destination-address 192.168.100.0 mask 255.255.255.0 //目標地址

service ftp //FTP服務

service http //HTTP服務

service icmp //Ping服務

action permit //行為:允許

這條安全策略的意思是:允許trust區域內的電腦訪問DMZ區域內的伺服器,但僅限於http、ftp,ping只是為了測試而已,加不加無所謂,先測試一下吧。

Client1能夠訪問Server1上面的HTTP服務了,緊接著再來一條上網的策略吧:

security-policy

rule name internet

source-zone dmz local trust //local是指防火牆本身,要不要允許連接網際網路,那就見仁見智了

destination-zone untrust //網際網路肯定是untrust區域

action permit

想上網際網路,只有安全策略還不行,還要配置NAT策略:

nat-policy

rule name internet

source-zone trust

action source-nat easy-ip

配置完成,來模擬一下防火牆故障,看看VRRP是否會自動切換,直接在模擬器中「停止」FW1,PC1上tracert檢查出路徑:

從上圖中可以看到,FW1故障之前,PC1是走PPPOE撥號的寬頻出去的,FW1故障掉線後,PC1就從固定IP的鏈路出去了。

再來看防火牆的VRRP狀態吧:

FW2已經接替FW1,成為VLAN100的Master設備,說明防火牆VRRP配置正確,及時響應,沒有影響PC上網;

再看一下交換機的VRRP,因為FW1的故障,核心交換機的VRRP也會感知,從而切換Master角色:

雖然只是FW1掛了,核心1在正常工作中,但是由於鏈路down了,所以,此刻的核心2還是獨自承擔了所有,VLAN10和VLAN20的數量流量全部走核心2了。

至此,雙防火牆+雙核心交換機的配置基本上完成,後面就是一些細節上的調整和完善了。

文章來源: https://twgreatdaily.com/zh-mo/1f5e6ae3a1efa334cc14a789cd0cb728.html