原因
IP (163.26.79.1) 在 gateway/NAT router 中的狀態「卡住」或 session 失效
-
外網無法連進,區網正常 → 顯示封包無法從 gateway 對你主機做 port forwarding 或送達。
-
重開機會讓 gateway 重新認識你的主機(重新發送 ARP 請求、重建 NAT 表、MAC/IP 對應表),所以就恢復正常。
解決辦法
建立一個腳本 /root/netfix.sh
#!/bin/sh
logger "[netfix] 啟動網路堆疊重建..."
service netif stop
service routing stop
sleep 2
service netif start
service routing start
logger "[netfix] 完成"
儲存後設定執行權限:
chmod +x /root/netfix.sh
執行:
sh /root/netfix.sh
設定排程自動重啟網路
crontab -e
加上一行,每天凌晨 2 點自動修復:
0 2 * * * /root/netfix.sh
查看記錄檔
grep netfix /var/log/cron
設定自動通知
Step 1. 安裝 msmtp
pkg install msmtp
Step 2. 申請 Gmail 「應用程式密碼」
https://myaccount.google.com/apppasswords
Step 3. 建立 msmtp 設定檔
# /usr/local/etc/msmtprc
defaults
auth on
tls on
tls_trust_file /usr/local/etc/ssl/cert.pem
logfile /var/log/msmtp.log
account gmail
host smtp.gmail.com
port 587
from your_email@gmail.com
user your_email@gmail.com
password your_app_password
account default : gmail
Step 4. 設定權限保護
chmod 600 /usr/local/etc/msmtprc
Step 5. 測試寄信
echo "測試內容" | msmtp -a gmail your_target_email@example.com
沒有留言:
張貼留言