Board logo

標題: Send e-mail for any change in WAN IP (public or private) [打印本頁]

作者: 角色    時間: 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

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

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

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

作者: gfx86674    時間: 2018-5-16 01:28

1.設定外寄信箱(區分POP3與Gmail信箱兩種設置,端看您個人環境):

POP3信箱(以Hinet個人信箱為例):

Gmail信箱:


DHCP-Clinet置入script:
  1. :global public ; :local current
  2. :if ([:len $public]=0) do={:set public "\?\?\?"}
  3. :if ($bound=1) do={:set current [/ip dhcp-c get [find interface=$interface] address] ; :set current [:pick $current 0 [:find $current "/"]]}

  4. :if ($bound=1 && $current!=$public) do={
  5. :local online false
  6. :while (!$online) do={
  7. :do {
  8. /tool e-mail send to=[/tool e-mail get from] subject="Current Address: $public => $current" body="Current Address: $current"
  9. :set online true ; :delay 5s} on-error={:delay 3s}}
  10. :set public $current
  11. }
複製代碼





歡迎光臨 電訊茶室 (http://telecom-cafe.com/forum/) Powered by Discuz! 7.2