2026年3月21日 星期六

Zabbix MTR Template Lab

 事前導讀

https://www.meinekleinefarm.net/zabbix-template-net-mtr-my-traceroute/

其它相關資訊

https://xrcd2.blogspot.com/2023/04/zabbix-template-net-mtr-json-report-on.html

https://xrcd2.blogspot.com/2024/06/zabbix-70-lts.html

https://xrcd2.blogspot.com/2026/02/oracle-linux-101.html

以下操作基於 Oracle 10.1 + Zabbix 7.0.23

監控目地為專線是否有異常

從 Firewall WAN Port 至 介接的 Next Hop Gateway/Router IP 異常及品質監控  

尤其是有二個以上的 WAN port 或使用 SD-WAN 的架構監控最為合適

如 




或其它 MTR 相關運用皆可.

對於 MTR 不太了解的人,推薦自行觀看其它高手提供的資訊

MTR:Linux 網路診斷工具使用教學
(G. T. Wang 的個人部落格)


以下運用皆基於 mtr 這個工具延伸而來.

前置作業  zabbix_server.conf

 vi /etc/zabbix/zabbix_server.conf


### Option: EnableGlobalScripts

#    Enable global scripts on Zabbix server.

#       0 - disable

#       1 - enable

#

# Mandatory: no

# Default:

# EnableGlobalScripts=1


EnableGlobalScripts=1



前置作業  Linux sudo 

vi /etc/sudoers 

zabbix ALL=(root) NOPASSWD: /usr/sbin/mtr , /usr/lib/zabbix/externalscripts/mtr.sh  

可視自行監控需求修改之


前置作業 抄改 mtr.sh

https://github.com/xenadmin/zabbix-templates/blob/master/zabbix-net-mtr/mtr.sh


#!/bin/bash

IP=$1

mtr -r -c3 -w -b -p -j $IP


dnf install mtr -y  

vi /usr/lib/zabbix/externalscripts/mtr.sh 

可視自行監控需求修改之如

cat /usr/lib/zabbix/externalscripts/mtr.sh 

#!/usr/bin/bash

IP=$1

/usr/sbin/mtr -n -r -c3 -w -b -p -j $IP

mrt 測試


json 格式輸出  (Template_Net_MTR.xml 輸入的格式一定要是 json 方可使用)

shell 測試


前置作業 WEB UI  [Administrator\General\Timeouts]

External check  30s

可視自行監控需求修改之



匯入 Template_Net_MTR.xml

https://github.com/xenadmin/zabbix-templates/blob/master/zabbix-net-mtr/Template_Net_MTR.xml



透過 Shell + Template 主要取得內容為

item key 

(1)mtr.hop.host[{#HOP_ID}]

(2)mtr.hop.avg[{#HOP_ID}]

(3)mtr.hop.loss[{#HOP_ID}]


(1)MTR 第 n 個節點 IP 

(2)MTR 第 n 個節點 IP 的 RTT 

(3)MTR 第 n 個節點 IP 的 ICMP Loss


[{#HOP_ID}] 是一個由小到大的整數數值 從 1,2,3...其它的資訊可參考 Template_Net_MTR.xml

以上資訊的取得可用於圖示或告警之使用,可視自行監控需求修改之



Item prototypes


含 DNS 解析看到的 MTR Hop 2 [History 資訊]



 -n, --no-dns   [含不 DNS 解析] [=>個人偏好,監控可自行定義加上 Trigger Name 用以區分之]




MTR 可以看到的資訊



告警規則定義 可視自行監控需求修改之

last(/HiNet-GW/mtr.hop.loss[2]) >= 10

(last(/HiNet-GW/mtr.hop.host[2]) <> last(/HiNet-GW/mtr.hop.host[2],#2) or last(/HiNet-GW/mtr.hop.host[2])="???")

....




Demo


新增監控



亦可自定 Interval



2026年3月13日 星期五

FortiGate SD-WAN Lab

 FortiGate SD-WAN Lab


實驗目地: 希望維持 WAN1 為主路由 )、 WAN2 為備路由 , 且 WAN2 的 Virtual Server 會通的設定方式.

又不影響到既有 WAN1上原有的任何服務或規則之下,加入新擴增 WAN2 的其它運用.

事前導讀請參關 FortiGate Policy Routes (PBR) Lab

 https://xrcd2.blogspot.com/2026/03/fortigate-policy-routes-pbr-lab.html


方案 (1) 浮動靜態路由模式 / 主備模式

 (設定簡略)

config router static

    edit 1

        set gateway 110.100.100.30

        set priority 1

        set device "port2"

    next

    edit 2

        set gateway 220.100.100.30

        set priority 2

        set device "port3"

    next

end



這個最為簡單,不需配合 Policy Routes (PBR) 相關設定. (推)



方案  (2) 軟體定義廣域網路(SD-WAN)模式.


這就需要大改了,但日後維運上更為方便.


SD-WAN移轉改接測試如下所示....

---> Rule 規則移轉 GG   (要人工介入大改後方可使用)

===> 這個方案需大改 [不推]


(設定簡略)

config system sdwan

    set status enable

    config zone

        edit "virtual-wan-link"

        next

    end

    config members

        edit 1

            set interface "port3"

            set gateway 220.100.100.30

        next

        edit 2

            set interface "port2"

            set gateway 110.100.100.30

        next

    end

    config health-check

        edit "WAN.1.GW"

            set server "110.100.100.30"

            set members 2

        next

        edit "WAN.2.GW"

            set server "220.100.100.30"

            set members 1

        next

    end

    config service

        edit 1

            set name "Prefer_WAN1"

            set mode priority

            set dst "all"

            set src "all"

            set health-check "WAN.1.GW"

            set priority-members 2 1

        next

    end

end


config router static

    edit 1

        set distance 1

        set sdwan-zone "virtual-wan-link"

    next

end


















DNAT




差異設定對照 rule

(1) 2 WAN

 


(2) SD-WAN 



差異設定對照 Static Routes

(1) 2 WAN



(2) SD-WAN 



Routing Table


(1) 2 WAN



(2) SD-WAN



SD-WAN Rule





FortiGate Policy Routes (PBR) Lab

 FortiGate Policy Routes (PBR) Lab

實驗目地: 希望維持 WAN1 為主路由 (Priority 10)、 WAN2 為備路由 (Priority 20), 且 WAN2 的 Virtual Server 會通.

實驗架構簡圖








Port3 Setting 


show routing table


 

Test WAN2 DNAT




順便再測一下 WAN1 DNAT 是否可以併存...(設定步驟這裡就省略了)



 

實驗設定(略)


config system interface

    edit "port1"

        set vdom "root"

        set ip 192.168.1.1 255.255.255.0

        set allowaccess ping https ssh http fgfm

        set type physical

        set snmp-index 1

    next

    edit "port2"

        set vdom "root"

        set ip 110.100.100.1 255.255.255.224

        set allowaccess ping

        set type physical

        set snmp-index 2

    next

    edit "port3"

        set vdom "root"

        set ip 220.100.100.1 255.255.255.224

        set allowaccess ping

        set type physical

        set src-check disable

        set snmp-index 3

    next



config firewall policy

    edit 1

        set name "WEB-IN"

        set uuid 872489d8-1ee5-51f1-91a3-9838e225d9f8

        set srcintf "port3"

        set dstintf "port1"

        set action accept

        set srcaddr "all"

        set dstaddr "WEB-DNAT"

        set schedule "always"

        set service "ALL"

    next

end





config firewall vip

    edit "WEB-DNAT"

        set uuid 528b1c78-1ee5-51f1-b558-b153d89f1cf2

        set extip 220.100.100.20

        set mappedip "192.168.1.20"

        set extintf "port3"

    next

end




config router static

    edit 1

        set gateway 110.100.100.30

        set device "port2"

    next

    edit 2

        set gateway 220.100.100.30

        set distance 20

        set device "port3"

    next

end



config router policy

    edit 1

        set input-device "port1"

        set srcaddr "WEB-Server"

        set dstaddr "all"

        set gateway 220.100.100.30

        set output-device "port3"

    next

end