最近重度用hetrixtools做探针和提醒 免费版也够用。但win上有icmp防火墙,需要导入白名单,而官方好像没有提供。于是改造了linux的获取方法。
参考⬇️ 但github上的好像很久更新了,应该就是python写的小工具
https://docs.hetrixtools.com/installing-the-windows-server-monitoring-agent/
Linux的csf
https://docs.hetrixtools.com/how-to-whitelist-our-uptime-monitoring-nodes-in-csf/
直接在powershell里以管理员身份运行;并在防火墙高级管理里面关闭其他ban icmp v4的规则;下面的规则是除了白名单都block。装好后看面板就显示正常了。
# 1. 从 HetrixTools 获取监控节点数据
$data = Invoke-RestMethod -Uri "https://hetrixtools.com/resources/uptime-monitor-ips.txt"
# 2. 逐行解析提取 IP(过滤空行,以空格分割并取第二列的值)
$ips = $data -split '\r?\n' | Where-Object { $_ -match '\S' } | ForEach-Object {
$parts = $_ -split '\s+'
$parts[1]
}
# 3. 设置 Windows 防火墙规则名称
$ruleName = "HetrixTools_Uptime_Monitors_Whitelist"
# 4. 创建或更新防火墙规则 (允许入站)
if (Get-NetFirewallRule -DisplayName $ruleName -ErrorAction SilentlyContinue) {
# 如果规则已存在,则更新 IP 列表
Set-NetFirewallRule -DisplayName $ruleName -RemoteAddress $ips
Write-Host "已成功更新现有的防火墙白名单规则。" -ForegroundColor Green
} else {
# 如果规则不存在,则新建一条规则
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Action Allow -RemoteAddress $ips
Write-Host "已成功创建并添加防火墙白名单规则。" -ForegroundColor Green
}