indoglobal.com
Langsung ke: navigasi, cari

Dynamic DNS menggunakan Mikrotik

Revisi per 21 September 2014 08.04; Docs (bicara | kontrib)

Gunakan salah satu script berikut ini untuk supaya perangkat Mikrotik dapat melakukan update Dynamic DNS secara otomatis:

Alternatif Pertama

## Dynamic DNS script for indoglobal.com service
 
## Script Settings
 
# get these from usage information in control panel
:local dyndnsupdateurl "http://mail.example.net/nic/update"
:local dyndnsuser "your username"
:local dyndnspass "your password"
 
# the name of interface that gets dynamic IP address
:local dyndnsinterface "your interface"
 
## do not modify after this line
 
:local dyndnsdomain "$dyndnsuser"
:local IpCurrent [/ip address get [find interface=$dyndnsinterface] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={ 
  :if ( [:pick $IpCurrent $i] = "/") do={ 
    :local NewIP [:pick $IpCurrent 0 $i];
    :if ([:resolve $dyndnsdomain] != $NewIP) do={
      /tool fetch mode=http user=$dyndnsuser password=$dyndnspass url="$dyndnsupdateurl\3Fhostname=$dyndnsdomain&myip=$NewIP" keep-result=no
      :log info "Dynamic DNS Update: $dyndnsdomain - $NewIP"
     }
   } 
}

Script di atas adalah adaptasi dari script Dynamic DNS untuk No-IP yang ada pada Mikrotik Wiki.

Alternatif Kedua

Versi ini kompatibel untuk Mikrotik versi lama (3.x).

## Dynamic DNS script for indoglobal.com services
 
# User variables
:local dyndnsupdatehostname "mail.example.net"
:local dyndnsuser "username"
:local dyndnspass "password"
:local dyndnsinterface "interface"
 
# Get the current IP address
:local curip [ /ip address get [/ip address find interface=$dyndnsinterface ] address ]
 
# Strip the net mask
:for i from=( [:len $curip] - 1) to=0 do={
  :if ( [:pick $curip $i] = "/") do={ 
    :set curip [:pick $curip 0 $i]
  } 
}
 
# Did we get an IP address to compare?
:if ([ :typeof $curip ] = nil ) do={
   :log info ("Dynamic DNS: No IP address present on " . $dyndnsinterface)
} else={
  :local dnsip [:resolve $dyndnsuser];
  :if ($curip != $dnsip) do={
    :log info ("Dynamic DNS: Sending update " . $dnsip)
    /tool fetch address="dyndnsupdatehostname" src-path="nic/update\3Fhostname=$dyndnsuser&myip=$curip" user=$dyndnsuser password=$dyndnspass keep-result=no
  } else={ 
    :log info "Dynamic DNS: No update required"
  }
}

Script di atas adalah adaptasi dari script dynamic DNS untuk No-IP dari Amiga Projects.