電訊茶室's Archiver

角色 發表於 2018-5-14 19:34

Send e-mail for any change in WAN IP (public or private)

因为大陆有很多地方都用private IP,但是private IP很多DNS都提供支持,我接的以前好像DynDNS是支持的。我记得RouterOS好像有script,如果IP有变动,可以send script,群里的某位member都有这样的script,不知道是否可以share出来呢?

主要用途,链接RB后面的Asterisk Server。

谢谢!

角色 發表於 2018-5-14 19:49

找到一个[code]
:local oldip [/ip firewall address-list get [find list="externalip"] address];
:local newip [/ip address get [find interface="ether1"] address];
:local newip [:pick $newip 0 [:find $newip "/"]];

:if ($newip != $oldip) do={
    :put "ip address $old changed to $newip";
    /ip firewall address-list set [find list="externalip"] address=$newip

    :put "Sending e-mail.";
    /tool e-mail send \
        to="someone@somewhere.com" \
        subject=("$[/system identity get name] Ether1 address change") \
        body=("Your Ether1 address has just been changed:\n\nOld: " . $oldip . "\nNew: " . $newip);
}
[/code]

gfx86674 發表於 2018-5-16 01:28

1.設定外寄信箱(區分POP3與Gmail信箱兩種設置,端看您個人環境):
[img]https://i.imgur.com/Nq14cyH.png[/img]
POP3信箱(以Hinet個人信箱為例):
[img]https://i.imgur.com/srqIw8N.png[/img]
Gmail信箱:
[img]https://i.imgur.com/sM46jxH.png[/img]

DHCP-Clinet置入script:
[img]https://i.imgur.com/8c1NC3P.png[/img][code]:global public ; :local current
:if ([:len $public]=0) do={:set public "\?\?\?"}
:if ($bound=1) do={:set current [/ip dhcp-c get [find interface=$interface] address] ; :set current [:pick $current 0 [:find $current "/"]]}

:if ($bound=1 && $current!=$public) do={
:local online false
:while (!$online) do={
:do {
/tool e-mail send to=[/tool e-mail get from] subject="Current Address: $public => $current" body="Current Address: $current"
:set online true ; :delay 5s} on-error={:delay 3s}}
:set public $current
}[/code]

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.