1. 環境說明
- 防火牆型號:FortiGate 61F
- 防火牆版本: 7.2.8
- Switch型號:FortiSwitch 124F-POE
- Switch版本:7.2.8
2. FortiSwitch管理模式
FortiSwitch管理模式可區分為三種,從7.2版開始切換管理模式不會重新開機
2.1. Standlone
- 使用FortiSwitch本身的GUI或CLI管理
- 不需要有FortiGate
config switch auto-network set status disableend2.2. Managed Switch
- 使用FortiGate GUI或CLI管理
- FortiSwitch需連接到FortiLink Interface
config switch auto-network set status enableend2.3. FortiLan Cloud
- Standlone Switch但是使用FortiLan Cloud管理
- FortiSwitch本身要能夠上網
config switch auto-network set status disableendconfig switch flan-cloud set status enableend3. FortiLink管理模式下FortiSwitch上線流程
- 決定部署模式
- 確定或設定FortiGate的FortiLink
- 確定或設定FortiSwitch auto-discovery-fortilink
- 授權FortiSwitch
4. FortiLink
- FortiLink是一種專屬的管理協議可使FortiGate藉由此協議管理設定FortiSwitch,在多數的FortiGate上會有預設的Aggregation Interface啟用FortiLink功能但也可以自行在Physical Interface、Software Switch、Hardware Switch啟用該功能,端看要採用何種部署方式。
- 在使用FortiLink管理FortiSwitch時,FortiGate角色就是FortiSwitch的控制器,此時的FortiSwitch被稱為managed switch。
- 從FortiSwitch 7.2版開始已經不使用switch-mgmt-mode設定來指定FortiSwitch是standalone或managed模式,取而代之的是config switch auto-network,預設為enable,故當連接到到FortiLink Interface時會自動切換至FortiLink模式且不會重開。
- Fortiswitch IP會經由FortiGate上的FortiLink Interface DHCP Server派發,若要確保IP均不會變動可以設定DHCP保留區來達成。
- 被FortiGate控管的FortiSwitch設定會寫在FortiGate上故只要備份FortiGate設定檔即可。
不要直接在被管理的FortiSwitch上更改設定,因為FortiSwitch不會將更改的設定同步到FortiGate故會造成兩邊資訊不一致,且後續也可能會被FortiGate上的設定覆蓋。- FortiLink Interface預設允許untagged及tagged frames,Native Vlan為4094,此Vlan也是管理使用的vlan。
4.1. FortiGate Interface啟用FortiLink功能方式
僅能於CLI啟用,啟用完成後該Interface就可以用來連接FortiSwitch
# 進入Interface設定模式FortiGate-61F # config system interface
# 編輯要啟用FortiLink功能介面FortiGate-61F (interface) # edit dmz
# 啟用FortiLinkFortiGate-61F (dmz) # set fortilink enable
# 結束編輯FortiGate-61F (dmz) # end啟用完成後可以於GUI查看確認

4.2. FortiSwitch啟用auto-discovery-fortilink功能方式
從FortiSwitch 7.2.0版本以後預設所有的Interface都會啟用故不需要額外設定,若是較早期版本則需查看手冊確認哪些介面有啟用,有啟用的Interface才會自動查找FortiLink Interface
# 進入Interface設定模式S124 # config switch interface
# 編輯要啟用auto-discovery-fortilink功能介面S124 (interface) # edit port1
# 啟用auto-discovery-fortilinkS124 (port1) # set auto-discovery-fortilink enable
# 結束編輯S124 (port1) # end5. 授權FortiSwitch
FortiSwitch連接上FortiGate後需要授權才可以使用

也可以設定FortiLink Interface開啟自動授權FortiSwitch功能

6. 部署模式
FortiSwitch有多種部署方式故於安裝前需先評估要採取哪種方式
6.1. 單一台FortiSwitch
可分為使用Physical Port或LAG Port連接兩種設定


6.2. 多台FortiSwitch


- FortiSwitch之間以Ring方式連接
- 若FortiLink Type是Aggregate則可以將最後一台FortiSwitch連接到FortiLink Interface但是FortiLink split interface功能要打開,此時最後一台的連線會處於Standby狀態。
**僅有當第一台FortiSwitch介面Down時該介面才會被使用**,使用此方式可以提供上行鏈路的備援,切換會有10-15秒鐘左右的中斷時間


6.3. FortiLink Type為hardware或software switch


- 因為所有FortiSwitch都是直接連線到FortiGate故FortiSwitch之間的Layer 2流量都需經由FortiGate橋接進而增加FortiGate額外負擔
故此種模式較不建議使用 - 這種模式下FortiGate上的Switch Interface可以接其他設備,但該設備要支援IEEE 802.1q VLAN tagging


6.4. FortiLink mode over a layer-3 network
- 需先設定FortiSwitch IP及路由確保可以到達FortiGate的FortiLink Interface
- 需先設定FortiGate Policy允許FortiSwitch及FortiGate的FortiLink Interface之間的流量
- 若有Layer 3設定相關需求僅能連線至該FortiSwitch設定無法於FortiGate上設定,包含Vlan Interface及其IP

6.4.1. 在FortiSwitch上的設定
設定IP Address


新增靜態路由


設定靜態查找FortiGate FortiLink Interface
config switch-controller global set ac-discovery-type static config ac-list edit <id> set ipv4-address <IPv4_address> next endend
設定Static ISL
config switch trunk edit <trunk_name> set static-isl enable set static-isl-auto-vlan {enable | disable} set members <switch_ports> nextend此處static-isl-auto-vlan設定為enable故當連接上FortiGate並授權後,其member port的native vlan會被變更為管理vlan 4094並且也會自動建立相關預設vlan

6.4.2. 在FortiGate上的設定
可以單獨使用一個physical port當作over layer3 FortiSwitch的FortiLink Interface,這樣在vlan建立時就可以與其他FortiLink區隔開來,這個physical port不一定要有接線,設定方式請參考FortiGate Interface啟用FortiLink功能

新增Policy允許FortiSwitch到FortLink Interface流量,設定方式請參考設定Security Policy以允許訪問FortiLink Interface

授權FortiSwitch,設定方式請參考授權FortiSwitch

6.4.3. 連接第二台FortiSwitch
若over layer3的FortiSwitch不止一台則設定步驟與第一台相同僅不需要設定static ISL
- 完成IP及路由設定
- 將第二台FortiSwitch連接第一台FortiSwitch此時就會自動建立ISL Link
- 設定靜態查找FortiGate FortiLink
- 於FortiGate完成授權

7. VLAN設定
7.1. 新增VLAN


| 編號 | 欄位名稱 | 欄位描述 |
|---|---|---|
| 1 | Interface Name | VLAN Interface名稱,可自定義 |
| 2 | VLAN ID | VLAN ID |
| 3 | Addressing mode | IP設定方式 |
| 4 | IP/Netmask | IP及子網路遮罩 |

| 編號 | 欄位名稱 | 欄位描述 |
|---|---|---|
| 1 | Administrative Access | Interface允許的功能。若要能夠連線此IP管理FortiGate需要勾選HTTPS |
| 2 | DHCP Server | 是否要啟用DHCP服務,若啟用則需設定派發範圍等資訊 |

| 編號 | 欄位名稱 | 欄位描述 |
|---|---|---|
| 1 | Network | 網路安全相關功能。如DHCP snooping就是用來防止未授權的DHCP Server |
| 2 | Traffic Shaping | 流量管控 |
7.2. 刪除VLAN
刪除VLAN時若Delete按鈕反灰則代表該介面有相關的關聯設定,需先將相關設定刪除才可以刪除此VLAN,相關設定可以使用Ref欄位查看,最常見的就是未關閉DHCP Server服務

7.3. 賦予VLAN到FortiSWitch Port
- Native VLAN就是Untagged VLAN,此VLAN Frames傳送出去時不會加Tag其餘VLAN則會;收到Untagged Frames時則會轉發至此VLAN
- Allowed VLAN部分則是允許接收及傳送的VLAN,
Native VLAN預設為允許傳送及接收故不需要額外加入Allowed VLAN清單裡面 - FortiSwitch Port預設接收所有802.1Q Untagged或Tagged Frames,但會再比對Native VLAN及Allowed VLANs清單決定是否放行,若要變更此行為可使用CLI實施更改
config switch interfaceedit <interface>set discard-mode <all-tagged | all-untagged | none>end修改Native VLAN



要同時設定多個Interface可以使用shift範圍選取或ctrl特定選取來達到,此處為修改Allowed VLANs



若Port是Trunk(Link Aggregation Group)介面的成員則VLAN僅需設定Trunk介面即可

8. Trunk(Link Aggregation Group)設定
8.1. 新增Trunk


| 編號 | 欄位名稱 | 欄位描述 |
|---|---|---|
| 1 | Name | Trunk Group名稱 |
| 2 | MC-LAG | 僅有在已經設定完成MCLAG Peer Group的交換器才可啟用此選項,啟用後Trunk即可跨兩台在MCLAG Group裡的FortiSwitch |
| 3 | Mode | Trunk模式。 - Static: 不論對端是否有設定Link Aggregation一率啟用。 - Passive LACP: 僅有接受到對端發送的LACP封包時才會啟用。 - Active LACP: 主動發送給對端LACP封包協商啟用Link Aggregation |
| 4 | Trunk Members | 選擇要加入Link Aggregation的Port |
選擇Members


8.2. 刪除Trunk

9. FortiSwitch Port設定
- STP建議都要啟用
- 若是連接設備則建議可以設定Edge Port、BPDU Guard、DHCP Snopping
- 若是連接第三方交換器則建議可以設定Loop Guard、DHCP Snopping
- 實際設定功能仍需依照實際環境調整
9.1. DHCP Snopping
- 此功能是用於防止未授權的DHCP Server,需先於VLAN啟用此功能然後再設定哪些Port為Trusted,僅有Trusted Port才會轉發DHCP OFFER及ACK封包,Untrusted Port則會丟棄,故Client就不會收到未授權的DHCP Server回覆
- 預設FortiSwitch上的Port都是Untrsuted,故僅需要針對要變更為Trusted Port部分做設定
- 預設FortiLink Interface為Trusted
啟用DHCP Snooping功能


設定Port為Untrusted

9.2. STP
Spanning Tree Protocol (STP) 主要用於避免網路迴圈,當兩台交換器之間有多條線路連線時就僅會保持一條線路可轉發。此選項預設啟用。

9.3. Loop Guard
- 當STP啟用時如果交換器從多個Port收到同一台交換器的BPDU,則判定兩者之間有多條線路故會block多餘的Port,但在某些情況可能無法阻止迴圈,例如AB兩台交換器彼此之間有兩條線路連接,但B交換器本身發生迴圈因而CPU負載過高造成無法發送BPDU時會讓A交換器認為它跟B之前沒有多條線路連接進而所有的Port都進入轉發狀態使得A交換器也有迴圈情形,
- 為了避免這種情形可以設定Loop Guard。當在計數器到期之前若都未收到BPDU封包則Port會進入 Loop Inconsistent State狀態而不轉發封包。
- 此選項預設停用。
- Edge Port無法設定Loop Guard
- Root Guard及Loop Guard不能同時設定

9.4. Edge Port
- 所謂的Edge Port就是該Port會啟用Portfast功能可以在連接設備後不用經歷Spanning Tree的Listening及Learning直接就是Fordwarding狀態,但是若收到BPDU封包則就會依照正常程序進入Listening及Learning狀態
- 預設所有的FortiSwitch Port都是設定為Edge Port

9.5. STP BPDU Guard
- 若Port收到BPDU則會禁止轉發流量。可用於防止接入其他網路設備,但僅限於此網路設備會發送BPDU封包情況下。
- 此選項預設停用。

9.6. STP Root Guard
- 當Port啟用了STP Root Guard並收到優於現有 Root Bridge 的 BPDU 時,該Port會被block,進入 Root Inconsistent 狀態,以防止新接入的設備成為Root Bridge進而造成整體Spanning Tree變動。
- 僅需於可能接入交換器的Port啟用,
不可於連接既有Root Bridge的Port啟用,會造成所有的Port被block。 - 此選項預設停用

10. Quarantines
此功能可以用於隔離特定的Mac Address,當FortiSwitch Port偵測到被隔離的Mac Address時就會將該Port Vlan改成quarantine vlan
11. 設定Security Policy以允許訪問FortiLink Interface
在某些情形下需要能夠從外部訪問FortiSwitch(如需要使用SNMP監控FortiSwitch)這時就需要建立Security Policy,但在GUI上無法在Security Policy中選擇Interface是FortiLink Interface僅能於CLI設定,Policy建立後就可以到GUI修改其他設定
config firewall policy edit <policy_ID> set name <policy_name> set srcintf <FortiGate port> set dstintf <FortiLink> set action accept set srcaddr <Source Address> set dstaddr <Destination Address> set schedule "always" set service <Destination Service> nextend
12. 設定FortiSwitch可供存取的管理服務
- FortiGate預設是使用access profile名稱為”default”的設定套用到各台FortiSwitch,故可以直接修該此policy或新建一個policy關聯到要使用的FortiSwitch
- internal-allowaccess指的是使用data port當Fortilink的Fortiswitch
- mgmt-allowaccess指的是使用management port當Fortilink的Fortiswitch,通常是指FortiGate over Layer 3網路管理FortiSwitch且FortiSwitch是使用Management Port與FortiLink溝通情形
新增或修改access profile
config switch-controller security-policy local-access edit <policy_name> set mgmt-allowaccess <options> set internal-allowaccess <options> nextend
賦予FortiSwitch access profile
config switch-controller managed-switch edit <FrotiSwitch SN> set access-profile <local access policy name> nextend
13. 統一變更FortiSwitch密碼
FortiSwitch預設帳號為admin,密碼為無,登入後即可修改密碼但若要所有FortiSwitch都使用相同密碼可於FortiGate設定switch profile
config switch-controller switch-profile edit "default"
# 啟用密碼覆蓋功能以讓FortiGate上設定的密碼取代FortiSwitch本機設定的密碼 set login-passwd-override enable
# 設定要覆蓋FortiSwitch的密碼 set login-passwd <new password> nextend預設所有FortiSwitch均使用switch profile名稱為”default”的設定檔但也可以針對特定FortiSwitch套用不同設定檔
config switch-controller managed-switch edit "<FortiSwitch SN>" set switch-profile <profile name>end以上方式僅適用於修改admin帳號,若要建立額外帳號或設定額外帳號密碼僅能利用FortiGate Custom Script功能
14. SNMP設定
- 需建立Security Policy以允許SNMP流量到FortiSwitch或FortiSwitch SNMP Trap流量到監控Server
- 需允許FortiSwitch Interface SNMP管理存取
- 可選擇使用全域設定或針對特定FortiSwitch單獨設定
14.1. 全域設定
14.1.1. SNMP System Info設定
status需設定為enable才會開啟snmp功能
config switch-controller snmp-sysinfo set status enable set description <system_description> set contact-info <contact_information> set location <FortiGate_location>end
14.1.2. SNMP Community設定
status要設定為enable才會啟用此community,hosts為允許的來源IP以及snmp trap要發送的主機,若單純只是要允許任意主機使用snmp監控可以設定為0.0.0.0/0
config switch-controller snmp-community edit <SNMP_community_entry_identifier> set name <SNMP_community_name> set status enable set query-v1-status enable set query-v1-port <0-65535; the default is 161> set query-v2c-status enable set query-v2c-port <0-65535; the default is 161> set trap-v1-status enable set trap-v1-lport <0-65535; the default is 162> set trap-v1-rport <0-65535; the default is 162> set trap-v2c-status enable set trap-v2c-lport <0-65535; the default is 162> set trap-v2c-rport <0-65535; the default is 162> set events {cpu-high mem-low log-full intf-ip ent-conf-change} config hosts edit <host_entry_ID> set ip <IPv4_address_of_the_SNMP_manager> end nextend
14.2. 針對特定FortiSwitch設定
14.2.1. SNMP System Info設定
config switch-controller managed-switch edit <FortiSwitch_serial_number> set override-snmp-sysinfo enable config snmp-sysinfo set status enable set description <system_description> set contact-info <contact_information> set location <FortiGate_location> end nextend14.2.2. SNMP Community設定
config switch-controller managed-switch edit <FortiSwitch_serial_number> set override-snmp-community enable config snmp-community edit <SNMP_community_entry_identifier> set name <SNMP_community_name> set status enable set query-v1-status enable set query-v1-port <0-65535; the default is 161> set query-v2c-status enable set query-v2c-port <0-65535; the default is 161> set trap-v1-status enable set trap-v1-lport <0-65535; the default is 162> set trap-v1-rport <0-65535; the default is 162> set trap-v2c-status enable set trap-v2c-lport <0-65535; the default is 162> set trap-v2c-rport <0-65535; the default is 162> set events {cpu-high mem-low log-full intf-ip ent-conf-change} config hosts edit <host_entry_ID> set ip <IPv4_address_of_the_SNMP_manager> end next end15. Syslog設定
- 需建立Security Policy以允許FortiSwitch Syslog流量到Syslog Server
- 可選擇使用全域設定或針對特定FortiSwitch單獨設定
15.1. 全域設定
config switch-controller remote-log edit {syslogd | syslogd2} set status {enable | *disable} set server <IPv4_address_of_remote_syslog_server> set port <remote_syslog_server_listening_port> set severity {emergency | alert | critical | error | warning | notification | *information | debug} set csv {enable | *disable} set facility {kernel | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | ntp | audit | alert | clock | local0 | local1 | local2 | local3 | local4 | local5 | local6 | *local7} nextend15.2. 針對特定FortiSwitch設定
config switch-controller managed-switch edit <FortiSwitch_serial_number> config remote-log edit {edit syslogd | syslogd2} set status {enable | *disable} set server <IPv4_address_of_remote_syslog_server> set port <remote_syslog_server_listening_port> set severity {emergency | alert | critical | error | warning | notification | *information | debug} set csv {enable | *disable} set facility {kernel | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | ntp | audit | alert | clock | local0 | local1 | local2 | local3 | local4 | local5 | local6 | *local7} next end nextend16. Port Mirroring
config switch-controller managed-switch edit <FortiSwitch_serial_number> config mirror edit <mirror_name>
# 設定此Mirror是否啟用 set status {active | inactive}
# 設定流量要複製到哪一個Port。需要先設定才可以設定src部分 set dst <port_name>
# 設定目的地Port是否要保留原有交換功能 set switching-packet {enable | disable}
# 設定流量從哪些Port進入時需複製 set src-ingress <port_name>
# 設定流量從哪些Port出去時需複製 set src-egress <port_name> next end next
17. 更換FortiSwitch
- 更換的FortiSwitch需要是相同型號
17.1. 更換未使用MCLAG的FortiSwitch
- 移除故障的FortiSwitch

- 取消故障的FortiSwitch授權
config switch-controller managed-switch edit <failed_FortiSwitch_serial_number> set fsw-wan1-admin disable end
- 若要更換的FortiSwitch並非全新設備請先恢復原廠預設值
execute factoryreset
-
將要更換的FortiSwitch升級到與故障FortiSwitch相同版本
-
執行更換指令
execute replace-device fortiswitch <failed_FortiSwitch_serial_number> <replacement_FortiSwitch_serial_number>
- 授權更換的交換器
config switch-controller managed-switch edit <replacement_FortiSwitch_serial_number> set fsw-wan1-admin enable end
- 連接更換的FortiSwitch

18. 重新開機

19. 升級Firmware








