воскресенье, 19 апреля 2015 г.

noip

Есть два маршрута на разные провайдеры, когда один активен(WAN1), второй нет.

# The RB interface global ddnsinterface
local status [ip route get value-name=active [find comment=WAN1]]
if ($status=true) do={:global ddnsinterface "wan1"} else={:global ddnsinterface "wan2"}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Define DDNS Accounts for RB Interfaces, one per interface.
# The RB interface
:global ddnsinterface
# The DDNS Provider (Choice of NOIP, DYNDNS or EVERYDNS)
:global ddnsprovider "NOIP"
# The Hostname to update.
:global ddnshost "1.sytes.net"
# Your Account Username
:global ddnsuser "user"
# Your Account Password
:global ddnspass "pass"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Define Global Variables
:global ddnssystem ("mt-" . [/system package get system version] )
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip;] = "nil" ) do={ :set ddnslastip "0" }
:global ddnsprovname
:global str
:global ddnsprovaddress
:if ($ddnsprovider="NOIP") do={
  :set ddnsprovname "NoIP"
  :set str "/nic/update?hostname=$ddnshost&myip=$ddnsip"
  :set ddnsprovaddress "dynupdate.no-ip.com"
}
if ($ddnsprovider="DYNDNS") do={
  :set ddnsprovname "DynDNS"
  :set str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
  :set ddnsprovaddress "members.dyndns.org"
}
if ($ddnsprovider="EVERYDNS") do={
  :set ddnsprovname "EveryDNS"
  :set str "/index.php?ver=0.1&ip=$ddnsip&domain=$ddnshost"
  :set ddnsprovaddress "dyn.everydns.net"
}

# Grab the current IP address on that interface.
:global ddnsip2 [/ip address get [/ip address find interface=$ddnsinterface ] address];
:set ddnsip [:pick $ddnsip2 0 [:find $ddnsip2 "/"]];
# Did we get an IP address to compare?
:if ([ :typeof $ddnsip;] = "nil" ) do={
   :log info ("NoIP: No ip address present on " . $ddnsinterface . ", please check.")
} else={
  :if ($ddnsip != $ddnslastip) do={
        :log info "$ddnsprovname: Sending UPDATE!"
         /tool fetch address=$ddnsprovaddress src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DDNS-".$ddnsprovname.".".$ddnshost)
  }
  :delay 1
  :set str [/file find name="DDNS-$ddnsprovname.$ddnshost"];
  /file remove $str
  :set ddnslastip $ddnsip
}
#:log info "DDNS Update script executed successfully."

Подписаться на новые статьи.

Комментариев нет:

Отправить комментарий