返回列表 發帖
本帖最後由 gfx86674 於 2018-3-19 00:13 編輯
有否可能 写个scripts 叫个router (routeros),自动更新完 IP 地址后,再自动发个e-mail 给自己邮箱呢? ...
vpn-learner 發表於 2018-3-18 01:33

可以啊,以dyndns為例:
  1. :local dyndnsuser "a123456"
  2. :local dyndnspass "123456"
  3. :local wan "ether1-wan"
  4. :local host "a123456.dyndns.org"

  5. :local public [/ip address get interface=$wan address] ; :set public [:pick $public 0 [:find $public "/"]]
  6. :local past   [:resolve $host]
  7. :if ($past!=$public) do={
  8. /tool fetch address=members.dyndns.org mode=http user=$dyndnsuser password=$dyndnspass dst-path=DynDNS \
  9.       src-path="/nic/update\?hostname=$host&myip=$public&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
  10. :delay 3s ; /file remove DynDNS

  11. :local date [/system clock get date]
  12. :local mm [:find 0,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $date 0 3]] ; :if ($mm<10) do={:set mm "0$mm"}
  13. :set date "$mm$[:pick $date 3 11]"

  14. :local title   "Update $host : $past => $public"
  15. :local content "$wan address changed at $[/system clock get time] $date"
  16. /tool e-mail send to=74.125.129.108 subject=$title body="$content\n\r$title" port=587 start-tls=yes
  17. }
複製代碼

TOP

返回列表