本帖最後由 gfx86674 於 2018-3-19 00:13 編輯
有否可能 写个scripts 叫个router (routeros),自动更新完 IP 地址后,再自动发个e-mail 给自己邮箱呢? ...
vpn-learner 發表於 2018-3-18 01:33
可以啊,以dyndns為例:- :local dyndnsuser "a123456"
- :local dyndnspass "123456"
- :local wan "ether1-wan"
- :local host "a123456.dyndns.org"
- :local public [/ip address get interface=$wan address] ; :set public [:pick $public 0 [:find $public "/"]]
- :local past [:resolve $host]
- :if ($past!=$public) do={
- /tool fetch address=members.dyndns.org mode=http user=$dyndnsuser password=$dyndnspass dst-path=DynDNS \
- src-path="/nic/update\?hostname=$host&myip=$public&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
- :delay 3s ; /file remove DynDNS
- :local date [/system clock get date]
- :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"}
- :set date "$mm$[:pick $date 3 11]"
- :local title "Update $host : $past => $public"
- :local content "$wan address changed at $[/system clock get time] $date"
- /tool e-mail send to=74.125.129.108 subject=$title body="$content\n\r$title" port=587 start-tls=yes
- }
複製代碼 |