mnogoweb revised this gist 1 year ago. Go to revision
No changes
mnogoweb revised this gist 1 year ago. Go to revision
No changes
mnogoweb revised this gist 1 year ago. Go to revision
No changes
mnogoweb revised this gist 1 year ago. Go to revision
No changes
ik revised this gist 1 year ago. Go to revision
1 file changed, 6 insertions, 2 deletions
dyndns-mikrotik.sh
| @@ -1,4 +1,8 @@ | |||
| 1 | - | # Замените параметры ниже | |
| 1 | + | # !!! Замените параметры ниже !!! | |
| 2 | + | # <API_KEY> - ключ API вашего аккаунта | |
| 3 | + | # <DOMAIN> - доменное имя (например, router.ru) | |
| 4 | + | # <NAME> - поддомен в домене <DOMAIN>, либо "@" если нужно обновить IP для <DOMAIN> | |
| 5 | + | ||
| 2 | 6 | :local api_key "<API_KEY>" | |
| 3 | 7 | :local api_server "api.mnogoweb.com" | |
| 4 | 8 | :local domain "<DOMAIN>" | |
| @@ -28,5 +32,5 @@ | |||
| 28 | 32 | :log info ("UpdateDynDNS: Dyndns Update Result: ".$result) | |
| 29 | 33 | :put ("DynDNS Update Result: ".$result) | |
| 30 | 34 | } else={ | |
| 31 | - | :log info ("UpdateDynDNS: IP update is not needed") | |
| 35 | + | :log info ("UpdateDynDNS: IP update is not needed") | |
| 32 | 36 | } | |
ik revised this gist 1 year ago. Go to revision
1 file changed, 0 insertions, 0 deletions
gistfile1.txt renamed to dyndns-mikrotik.sh
File renamed without changes
ik revised this gist 1 year ago. Go to revision
1 file changed, 32 insertions
gistfile1.txt(file created)
| @@ -0,0 +1,32 @@ | |||
| 1 | + | # Замените параметры ниже | |
| 2 | + | :local api_key "<API_KEY>" | |
| 3 | + | :local api_server "api.mnogoweb.com" | |
| 4 | + | :local domain "<DOMAIN>" | |
| 5 | + | :local name "<NAME>" | |
| 6 | + | ||
| 7 | + | :global previousIP | |
| 8 | + | ||
| 9 | + | :log info ("UpdateDynDNS: api_server = $api_server") | |
| 10 | + | :log info ("UpdateDynDNS: api_key = $api_key") | |
| 11 | + | :log info ("UpdateDynDNS: domain = $domain") | |
| 12 | + | :log info ("UpdateDynDNS: name = $name") | |
| 13 | + | :log info ("UpdateDynDNS: previousIP = $previousIP") | |
| 14 | + | ||
| 15 | + | /tool fetch mode=http address="ip.ezit.hu" src-path="/ip.php" dst-path="/dyndns.checkip.html" | |
| 16 | + | :local result [/file get dyndns.checkip.html contents] | |
| 17 | + | :local resultLen [:len $result] | |
| 18 | + | :local startLoc 0 | |
| 19 | + | :local endLoc [:find $result " | |
| 20 | + | " -1] | |
| 21 | + | :local currentIP [:pick $result $startLoc $endLoc] | |
| 22 | + | :log info "UpdateDynDNS: currentIP = $currentIP" | |
| 23 | + | ||
| 24 | + | :if ($currentIP != $previousIP) do={ | |
| 25 | + | /tool fetch mode=https url="$api_server/v1/dns/dyndns?domain=$domain&name=$name" http-header-field="Authorization: Bearer $api_key" dst-path="/dyndns.txt" | |
| 26 | + | :local result [/file get dyndns.txt contents] | |
| 27 | + | :log info ("UpdateDynDNS: IP update needed") | |
| 28 | + | :log info ("UpdateDynDNS: Dyndns Update Result: ".$result) | |
| 29 | + | :put ("DynDNS Update Result: ".$result) | |
| 30 | + | } else={ | |
| 31 | + | :log info ("UpdateDynDNS: IP update is not needed") | |
| 32 | + | } | |