Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4caf6694f9 | ||
![]() |
e4cdf8df96 |
1 changed files with 429 additions and 107 deletions
522
dnsdrone.rsc
522
dnsdrone.rsc
|
@ -1,25 +1,10 @@
|
|||
#!rsc by RouterOS
|
||||
# DNSDrone for Mikrotik - DNS Record Updater for FreeIPA
|
||||
|
||||
# This script:
|
||||
# 1. Consolidates all configuration into a single CONFIG dictionary
|
||||
# 2. Includes a function for making FreeIPA API calls
|
||||
# 3. Gets current IP addresses from DHCP clients
|
||||
# 4. Compares with existing DNS records
|
||||
# 5. Updates records only when they differ
|
||||
# 6. Handles both IPv4 and IPv6 records
|
||||
# 7. Updates the prefix TXT record
|
||||
#
|
||||
# To use this:
|
||||
# 1. Replace the configuration values in the CONFIG dictionary
|
||||
# 2. Save it as a script in your Mikrotik router
|
||||
# 3. Schedule it to run periodically or trigger it manually
|
||||
#
|
||||
# Note: You might need to adjust the HTTP headers and API calls based on your specific FreeIPA version and requirements. Also, ensure your Mikrotik router has proper SSL/TLS # certificates installed for HTTPS communication with the FreeIPA server.
|
||||
|
||||
# Configuration Variables
|
||||
:local CONFIG {
|
||||
"wanInterface"="VLAN666_Altibox";
|
||||
"wanInterface"="VLAN666_WAN_Telenor";
|
||||
"IpaServer"="ipa.demo1.freeipa.org";
|
||||
"dnsZone"="demo1.freeipa.org";
|
||||
"IpaUser"="admin";
|
||||
|
@ -43,7 +28,7 @@
|
|||
"DoHserver"="one.one.one.one";
|
||||
|
||||
# Script options (true/false)
|
||||
"debug"="true"
|
||||
"Debug"="true"
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,9 +39,39 @@
|
|||
# Import config
|
||||
:local CONFIG $1;
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "";
|
||||
:put "* RouterOS-multiline authentication-command (what we want):";
|
||||
:put "";
|
||||
:put "/tool fetch url=\"https://$($CONFIG->"IpaServer")/ipa/session/login_password\" \\";
|
||||
:put " http-method=post \\";
|
||||
:put " http-header-field=\"Accept: text/plain, \\";
|
||||
:put " Content-Type: application/x-www-form-urlencoded, \\";
|
||||
:put " Referer: https://$($CONFIG->"IpaServer")/ipa,\\";
|
||||
:put " X-IPA-API-Version: $($CONFIG->"apiVersion")\" \\";
|
||||
:put " http-data=\"user=$($CONFIG->"IpaUser")&password=$($CONFIG->"IpaPassword")\" \\";
|
||||
:put " output=user-with-headers";
|
||||
:put "";
|
||||
:put "* Reverting to ugly curl+ssh workaround instead via the following command:";
|
||||
:put "";
|
||||
:put "/system ssh-exec \"$($CONFIG->"curlproxyserver")\" user=\"$($CONFIG->"curlproxyuser")\" \\";
|
||||
:put " command=\"curl -s -k -i -H 'Accept: text/plain' \\";
|
||||
:put " -H 'Content-Type: application/x-www-form-urlencoded' \\";
|
||||
:put " -H 'Referer: https://$($CONFIG->"IpaServer")/ipa' \\";
|
||||
:put " -H 'X-IPA-API-Version: $($CONFIG->"apiVersion")' \\";
|
||||
:put " --data-urlencode 'user=$($CONFIG->"IpaUser")' \\";
|
||||
:put " --data-urlencode 'password=$($CONFIG->"IpaPassword")' \\";
|
||||
:put " 'https://$($CONFIG->"IpaServer")/ipa/session/login_password'\" \\";
|
||||
:put " output-to-file=\"$($CONFIG->"cookiefile")\"";
|
||||
:put "";
|
||||
|
||||
|
||||
}
|
||||
|
||||
# Save Cookie-information in tempoary local file via ugly ssh hack
|
||||
|
||||
/system ssh "$($CONFIG->"curlproxyserver")" user="$($CONFIG->"curlproxyuser")" \
|
||||
/system ssh-exec "$($CONFIG->"curlproxyserver")" user="$($CONFIG->"curlproxyuser")" \
|
||||
command="curl -s -k -i -H 'Accept: text/plain' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-H 'Referer: https://$($CONFIG->"IpaServer")/ipa' \
|
||||
|
@ -80,7 +95,7 @@
|
|||
:if ($startIndex != -1) do={
|
||||
:set startIndex ($startIndex + 12)
|
||||
|
||||
:local endIndex [:find $fileContents "\n" $startIndex]
|
||||
:local endIndex [:find $fileContents "\r\n" $startIndex]
|
||||
:if ($endIndex = -1) do={
|
||||
:set endIndex [:len $fileContents]
|
||||
}
|
||||
|
@ -91,8 +106,8 @@
|
|||
# Cleaning up the cookiefile
|
||||
/file remove "$($CONFIG->"cookiefile")"
|
||||
|
||||
:put "DEBUG (function: GetIPACookie):;
|
||||
:put Ipakjeks: $cookie";
|
||||
# :put "DEBUG (function: GetIPACookie):;
|
||||
# :put Ipakjeks: $cookie";
|
||||
|
||||
# Output
|
||||
:return "$cookie";
|
||||
|
@ -113,43 +128,71 @@
|
|||
:local resultClean;
|
||||
|
||||
:if ($ConfigType = "ipv4address" ) do={
|
||||
|
||||
# Retrive information
|
||||
# Retrieve information with error handling
|
||||
:local dhcpError;
|
||||
:onerror dhcpError in={
|
||||
:set resultRAW [/ip dhcp-client get [/ip dhcp-client find interface="$($CONFIG->"wanInterface")"] address];
|
||||
} do={
|
||||
:put "* Warning: Failed to get DHCPv4 address for interface $($CONFIG->"wanInterface"): $dhcpError";
|
||||
# Set default value on error
|
||||
:set resultRAW "";
|
||||
}
|
||||
|
||||
|
||||
# Clean information
|
||||
# Clean information only if resultRAW was set successfully
|
||||
:if ([:len "$resultRAW"] != 0) do={
|
||||
:set resultClean [:pick "$resultRAW" 0 [:find "$resultRAW" "/"]];
|
||||
|
||||
# :put "DEBUG: resultClean: $resultClean";
|
||||
|
||||
} else={
|
||||
:set resultClean "NA";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
:if ($ConfigType = "ipv6address") do={
|
||||
|
||||
# Retrive information
|
||||
|
||||
:if ($ConfigType = "ipv6address" ) do={
|
||||
# Retrieve information with error handling
|
||||
:local dhcpError;
|
||||
:onerror dhcpError in={
|
||||
:set resultRAW [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface="$($CONFIG->"wanInterface")"] address];
|
||||
} do={
|
||||
:put "* Warning: Failed to get DHCPv6 address for interface $($CONFIG->"wanInterface"): $dhcpError";
|
||||
# Set default value on error
|
||||
:set resultRAW "";
|
||||
}
|
||||
|
||||
# Clean information
|
||||
# Clean information only if resultRAW was set successfully
|
||||
:if ([:len "$resultRAW"] != 0) do={
|
||||
:set resultClean [:pick "$resultRAW" 0 [:find "$resultRAW" ","]];
|
||||
|
||||
# :put "DEBUG: resultClean: $resultClean";
|
||||
} else={
|
||||
:set resultClean "NA";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
:if ($ConfigType = "ipv6prefix") do={
|
||||
|
||||
# Retrive information
|
||||
|
||||
|
||||
:if ($ConfigType = "ipv6prefix" ) do={
|
||||
# Retrieve information with error handling
|
||||
:local dhcpError;
|
||||
:onerror dhcpError in={
|
||||
:set resultRAW [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface="$($CONFIG->"wanInterface")"] prefix];
|
||||
} do={
|
||||
:put "* Warning: Failed to get DHCPv6 prefix for interface $($CONFIG->"wanInterface"): $dhcpError";
|
||||
# Set default value on error
|
||||
:set resultRAW "";
|
||||
}
|
||||
|
||||
# Clean information
|
||||
# Clean information only if resultRAW was set successfully
|
||||
:if ([:len "$resultRAW"] != 0) do={
|
||||
:set resultClean [:pick "$resultRAW" 0 [:find "$resultRAW" ","]];
|
||||
|
||||
# :put "DEBUG: resultClean: $resultClean";
|
||||
} else={
|
||||
:set resultClean "NA";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Output
|
||||
:return "$resultClean";
|
||||
|
||||
|
@ -171,35 +214,56 @@
|
|||
:local resultRAW;
|
||||
:local resultClean;
|
||||
|
||||
|
||||
:if ($ConfigType = "ipv4address" ) do={
|
||||
|
||||
# Retrive information
|
||||
:set resultRAW [/resolve "$RecordName" server="$($CONFIG->"DNSserver")" type=ipv4]
|
||||
|
||||
# Clean information
|
||||
:set resultClean "$resultRAW";
|
||||
|
||||
# :put "DEBUG: resultClean: $resultClean";
|
||||
|
||||
# Retrive information with error handling
|
||||
:local resolveError;
|
||||
:onerror resolveError in={
|
||||
:set resultRAW [/resolve "$RecordName" server="$($CONFIG->"DNSserver")" type=ipv4];
|
||||
} do={
|
||||
:put "* Warning: Failed to resolve IPv4 address for $RecordName: $resolveError";
|
||||
# You can set a default value or take alternative action
|
||||
:set resultRAW "";
|
||||
}
|
||||
|
||||
# Clean information (only if resultRAW was set successfully)
|
||||
:if ([:len "$resultRAW"] != 0) do={
|
||||
:set resultClean "$resultRAW";
|
||||
} else={
|
||||
:set resultClean "NA";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
:if ($ConfigType = "ipv6address" ) do={
|
||||
|
||||
# Retrive information
|
||||
:set resultRAW [/resolve "$RecordName" server="$($CONFIG->"DNSserver")" type=ipv6]
|
||||
|
||||
# Clean information
|
||||
:set resultClean "$resultRAW";
|
||||
|
||||
# :put "DEBUG: resultClean: $resultClean";
|
||||
|
||||
# Retrive information with error handling
|
||||
:local resolveError;
|
||||
:onerror resolveError in={
|
||||
:set resultRAW [/resolve "$RecordName" server="$($CONFIG->"DNSserver")" type=ipv6];
|
||||
} do={
|
||||
:put "* Warning: Failed to resolve IPv6 address for $RecordName: $resolveError";
|
||||
# You can set a default value or take alternative action
|
||||
:set resultRAW "";
|
||||
}
|
||||
|
||||
# Clean information (only if resultRAW was set successfully)
|
||||
:if ([:len "$resultRAW"] != 0) do={
|
||||
:set resultClean "$resultRAW";
|
||||
} else={
|
||||
:set resultClean "NA";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
:if ($ConfigType = "ipv6prefix") do={
|
||||
|
||||
# Fetch prefix TXT-record via DoH server:
|
||||
:set resultRAW [/tool fetch url="https://$($CONFIG->"DoHserver")/dns-query?name=$RecordName&type=TXT" http-method=get output=user http-header-field="accept: application/dns-json" as-value];
|
||||
:set resultRAW [/tool fetch \
|
||||
url="https://$($CONFIG->"DoHserver")/dns-query?name=$RecordName&type=TXT" \
|
||||
http-method=get http-header-field="accept: application/dns-json" \
|
||||
output=user as-value];
|
||||
|
||||
# :put "DEBUG: resultRAW: $resultRAW";
|
||||
|
||||
|
@ -252,39 +316,108 @@
|
|||
:local resultRAW;
|
||||
:local resultClean;
|
||||
|
||||
put "DEBUG: IPACookie: $IPACookie";
|
||||
put "DEBUG: ConfigType: $ConfigType";
|
||||
put "DEBUG: RecordName: $RecordName";
|
||||
put "DEBUG: RecordContent: $RecordContent";
|
||||
|
||||
:if ($ConfigType = "ipv4address" ) do={
|
||||
|
||||
# Construct valid json-data:
|
||||
# :local httpheader "\"Accept: application/json,Content-Type: application/json, Referer: https://$($CONFIG->"IpaServer")/ipa, X-IPA-API-Version: $($CONFIG->"apiVersion"), Cookie: $IPACookie \"\"";
|
||||
:local httpdata "{\"method\":\"dnsrecord_mod\",\"params\":[[\"$($CONFIG->"dnsZone")\",\"$RecordName.\"],{\"arecord\":\"$RecordContent\",\"dnsttl\":$($CONFIG->"recordTTL")}]}";
|
||||
:local IPACookieData "$IPACookie";
|
||||
|
||||
:local IPACookieData "$cookie";
|
||||
# :local IPACookieData "ipa_session=MagBearerToken=4ZTumSEI1zR%2fcPkbvlzM2lkT7CR9ojGOsvOzji0MO8ee61xUjZqXX3Ecs9n1FCHl0Vyn1U0EEooAAQk2DZ9GWT1Wt43Zx06sqDjDd5Ku8OJMa0W5SzkQuIQs%2f2hqkFoREevjwefgXurIlSxvDyVofXzJM726ZUAZsGICL9UawnWmo%2f7IVIqPRnNkb5g2NeMJKgThT0xuJ1G4nRY8w0CuIJV%2fJnVk9%2fjK%2bg%2bEjxhE3Lo%3d;path=/ipa;httponly;secure;";
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "* RouterOS-multiline update-command:";
|
||||
:put "";
|
||||
:put "/tool fetch url=\"https://$($CONFIG->"IpaServer")/ipa/session/json\" \\";
|
||||
:put " http-method=post \\";
|
||||
:put " http-header-field=\"Accept: application/json, \\";
|
||||
:put " Content-Type: application/json,\\";
|
||||
:put " Referer: https://$($CONFIG->"IpaServer")/ipa,\\";
|
||||
:put " X-IPA-API-Version: $($CONFIG->"apiVersion"),\\";
|
||||
:put " Cookie: $IPACookieData\" \\";
|
||||
:put " http-data=\"{\\\"method\\\":\\\"dnsrecord_mod\\\",\\\"params\\\":[[\\\"$($CONFIG->"dnsZone")\\\",\\\"$RecordName.\\\"],{\\\"arecord\\\":\\\"$RecordContent\\\",\\\"dnsttl\\\":$($CONFIG->"recordTTL")}]}\" \\";
|
||||
:put " keep-result=no";
|
||||
:put "";
|
||||
}
|
||||
|
||||
|
||||
put "DEBUG: (NEW)IPACookie = $IPACookie";
|
||||
put "DEBUG: IPACookieData = $IPACookieData";
|
||||
put "DEBUG: http-data=$httpdata";
|
||||
|
||||
/tool fetch url="https://$($CONFIG->"IpaServer")/ipa/session/json" \
|
||||
http-method=post \
|
||||
http-header-field="Accept: application/json,Content-Type: application/json,\
|
||||
http-header-field="Accept: application/json, \
|
||||
Content-Type: application/json,\
|
||||
Referer: https://$($CONFIG->"IpaServer")/ipa,\
|
||||
X-IPA-API-Version: $($CONFIG->"apiVersion"),\
|
||||
Cookie: $IPACookieData" \
|
||||
http-data="$httpdata" \
|
||||
http-data="{\"method\":\"dnsrecord_mod\",\"params\":[[\"$($CONFIG->"dnsZone")\",\"$RecordName.\"],{\"arecord\":\"$RecordContent\",\"dnsttl\":$($CONFIG->"recordTTL")}]}" \
|
||||
keep-result=no
|
||||
|
||||
# http-data="{\"method\":\"dnsrecord_mod\",\"params\":[[\"$($CONFIG->"dnsZone")\",\"$RecordName.\"],{\"arecord\":\"$RecordContent\",\"dnsttl\":$($CONFIG->"recordTTL")}]}" \
|
||||
# Cookie: $IPACookie" \
|
||||
|
||||
}
|
||||
|
||||
:if ($ConfigType = "ipv6address" ) do={
|
||||
|
||||
:local IPACookieData "$IPACookie";
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "* RouterOS-multiline update-command:";
|
||||
:put "";
|
||||
:put "/tool fetch url=\"https://$($CONFIG->"IpaServer")/ipa/session/json\" \\";
|
||||
:put " http-method=post \\";
|
||||
:put " http-header-field=\"Accept: application/json, \\";
|
||||
:put " Content-Type: application/json,\\";
|
||||
:put " Referer: https://$($CONFIG->"IpaServer")/ipa,\\";
|
||||
:put " X-IPA-API-Version: $($CONFIG->"apiVersion"),\\";
|
||||
:put " Cookie: $IPACookieData\" \\";
|
||||
:put " http-data=\"{\\\"method\\\":\\\"dnsrecord_mod\\\",\\\"params\\\":[[\\\"$($CONFIG->"dnsZone")\\\",\\\"$RecordName.\\\"],{\\\"aaaarecord\\\":\\\"$RecordContent\\\",\\\"dnsttl\\\":$($CONFIG->"recordTTL")}]}\" \\";
|
||||
:put " keep-result=no";
|
||||
:put "";
|
||||
}
|
||||
|
||||
/tool fetch url="https://$($CONFIG->"IpaServer")/ipa/session/json" \
|
||||
http-method=post \
|
||||
http-header-field="Accept: application/json, \
|
||||
Content-Type: application/json,\
|
||||
Referer: https://$($CONFIG->"IpaServer")/ipa,\
|
||||
X-IPA-API-Version: $($CONFIG->"apiVersion"),\
|
||||
Cookie: $IPACookieData" \
|
||||
http-data="{\"method\":\"dnsrecord_mod\",\"params\":[[\"$($CONFIG->"dnsZone")\",\"$RecordName.\"],{\"aaaarecord\":\"$RecordContent\",\"dnsttl\":$($CONFIG->"recordTTL")}]}" \
|
||||
keep-result=no
|
||||
}
|
||||
|
||||
:if ($ConfigType = "ipv6prefix" ) do={
|
||||
|
||||
:local IPACookieData "$IPACookie";
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "* RouterOS-multiline update-command:";
|
||||
:put "";
|
||||
:put "/tool fetch url=\"https://$($CONFIG->"IpaServer")/ipa/session/json\" \\";
|
||||
:put " http-method=post \\";
|
||||
:put " http-header-field=\"Accept: application/json, \\";
|
||||
:put " Content-Type: application/json,\\";
|
||||
:put " Referer: https://$($CONFIG->"IpaServer")/ipa,\\";
|
||||
:put " X-IPA-API-Version: $($CONFIG->"apiVersion"),\\";
|
||||
:put " Cookie: $IPACookieData\" \\";
|
||||
:put " http-data=\"{\\\"method\\\":\\\"dnsrecord_mod\\\",\\\"params\\\":[[\\\"$($CONFIG->"dnsZone")\\\",\\\"$RecordName.\\\"],{\\\"txtrecord\\\":\\\"\\\\\\\"$RecordContent\\\\\\\"\\\",\\\"dnsttl\\\":$($CONFIG->"recordTTL")}]}\" \\";
|
||||
:put " keep-result=no";
|
||||
:put "";
|
||||
}
|
||||
|
||||
/tool fetch url="https://$($CONFIG->"IpaServer")/ipa/session/json" \
|
||||
http-method=post \
|
||||
http-header-field="Accept: application/json, \
|
||||
Content-Type: application/json,\
|
||||
Referer: https://$($CONFIG->"IpaServer")/ipa,\
|
||||
X-IPA-API-Version: $($CONFIG->"apiVersion"),\
|
||||
Cookie: $IPACookieData" \
|
||||
http-data="{\"method\":\"dnsrecord_mod\",\"params\":[[\"$($CONFIG->"dnsZone")\",\"$RecordName.\"],{\"txtrecord\":\"\\\"$RecordContent\\\"\",\"dnsttl\":$($CONFIG->"recordTTL")}]}" \
|
||||
keep-result=no
|
||||
}
|
||||
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put ""
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Output
|
||||
:return "$resultClean";
|
||||
|
@ -302,23 +435,28 @@
|
|||
|
||||
# Main Runtime
|
||||
|
||||
#:local IPACookie "drytest";
|
||||
:local IPACookie [$GetIPACookie $CONFIG];
|
||||
:put "DEBUG: IPACookie: $IPACookie";
|
||||
:local UpdateDNS;
|
||||
:local UpdateCurrentDualStackRecordv4;
|
||||
:local UpdateCurrentDualStackRecordv6;
|
||||
:local UpdateCurrentSingleStackRecordv4;
|
||||
:local UpdateCurrentSingleStackRecordv6;
|
||||
:local UpdateCurrentTXTRecordIPv6Prefix;
|
||||
|
||||
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "";
|
||||
:put "Debug: Collecting information";
|
||||
:put "#############################";
|
||||
:put "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
:local CurrentIPv4address [$GetLocalDynamicConfig $CONFIG ipv4address];
|
||||
:put "DEBUG CurrentIPv4address: $CurrentIPv4address";
|
||||
|
||||
:local CurrentIPv6address [$GetLocalDynamicConfig $CONFIG ipv6address];
|
||||
:put "DEBUG: CurrentIPV6address: $CurrentIPv6address";
|
||||
|
||||
:local CurrentIPv6prefix [$GetLocalDynamicConfig $CONFIG ipv6prefix];
|
||||
:put "DEBUG: CurrentIPv6prefix: $CurrentIPv6prefix";
|
||||
|
||||
|
||||
|
||||
|
||||
# "$($CONFIG->"dualStackName").$($CONFIG->"dnsZone")"
|
||||
|
||||
:local CurrentDualStackRecordName "$($CONFIG->"dualStackName").$($CONFIG->"dnsZone")";
|
||||
:local CurrentSingleStackIPv4RecordName "$($CONFIG->"ipv4OnlyName").$($CONFIG->"dnsZone")";
|
||||
|
@ -326,20 +464,204 @@
|
|||
:local CurrentTXTRecordIPv6PrefixName "$($CONFIG->"prefixTxtName").$($CONFIG->"dnsZone")";
|
||||
|
||||
:local CurrentDualStackRecordv4 [$GetDynamicDNSRecords $CONFIG ipv4address $CurrentDualStackRecordName ];
|
||||
:put "DEBUG: Dual-stack: $CurrentDualStackRecordName ipv4-resolves as $CurrentDualStackRecordv4";
|
||||
|
||||
:local CurrentDualStackRecordv6 [$GetDynamicDNSRecords $CONFIG ipv6address $CurrentDualStackRecordName ];
|
||||
:put "DEBUG: Dual-stack: $CurrentDualStackRecordName ipv6-resolves as $CurrentDualStackRecordv6";
|
||||
|
||||
:local CurrentSingleStackRecordv4 [$GetDynamicDNSRecords $CONFIG ipv4address $CurrentSingleStackIPv4RecordName ];
|
||||
:put "DEBUG: Single-stack-IPv4: $CurrentSingleStackIPv4RecordName ipv4-resolves as $CurrentSingleStackRecordv4";
|
||||
|
||||
:local CurrentSingleStackRecordv6 [$GetDynamicDNSRecords $CONFIG ipv6address $CurrentSingleStackIPv6RecordName ];
|
||||
:put "DEBUG: Single-stack-IPv6: $CurrentSingleStackIPv6RecordName ipv6-resolves as $CurrentSingleStackRecordv6";
|
||||
|
||||
:local CurrentTXTRecordIPv6Prefix [$GetDynamicDNSRecords $CONFIG ipv6prefix $CurrentTXTRecordIPv6PrefixName ];
|
||||
:put "DEBUG: $CurrentTXTRecordIPv6PrefixName resolves as $CurrentTXTRecordIPv6Prefix";
|
||||
|
||||
:local DebugUpdate [$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv4address $CurrentSingleStackIPv4RecordName $CurrentIPv4address ];
|
||||
:put "DEBUG: $DebugUpdate";
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "* CurrentIPv4address via DHCPv4 on '$($CONFIG->"wanInterface")' is '$CurrentIPv4address'";
|
||||
:put "* CurrentIPv6address via DHCPv6 on '$($CONFIG->"wanInterface")' is '$CurrentIPv6address'";
|
||||
:put "* CurrentIPv6prefix via DHCPv6 on '$($CONFIG->"wanInterface")' is '$CurrentIPv6prefix'";
|
||||
:put "";
|
||||
:put "* '$CurrentDualStackRecordName' has the following IPv4-(A)-record '$CurrentDualStackRecordv4'";
|
||||
:put "* '$CurrentDualStackRecordName' has the following IPv6-(AAAA)-record '$CurrentDualStackRecordv6';"
|
||||
:put "* '$CurrentSingleStackIPv4RecordName' has the following IPv4-(A)-record '$CurrentSingleStackRecordv4'";
|
||||
:put "* '$CurrentSingleStackIPv6RecordName' has the following IPv6-(AAAA)-record '$CurrentSingleStackRecordv6';"
|
||||
:put "* '$CurrentTXTRecordIPv6PrefixName' has the following prefix-(TXT)-record '$CurrentTXTRecordIPv6Prefix'";
|
||||
|
||||
}
|
||||
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "";
|
||||
:put "Debug: Evaluating information";
|
||||
:put "#############################";
|
||||
:put "";
|
||||
}
|
||||
|
||||
|
||||
if (("$CurrentDualStackRecordv4" != "$CurrentIPv4address" ) and \
|
||||
([:typeof [:toip "$CurrentIPv4address"]] = "ip")) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* '$CurrentDualStackRecordName' needs to update the IPv4-(A)-record";
|
||||
|
||||
}
|
||||
|
||||
:set $UpdateDNS "true";
|
||||
:set $UpdateCurrentDualStackRecordv4 "true";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (("$CurrentDualStackRecordv6" != "$CurrentIPv6address" ) && \
|
||||
([:typeof [:toip6 "$CurrentIPv6address"]] = "ip6")) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* '$CurrentDualStackRecordName' needs to update the IPv6-(AAAA)-record";
|
||||
|
||||
}
|
||||
|
||||
:set $UpdateDNS "true";
|
||||
:set $UpdateCurrentDualStackRecordv6 "true";
|
||||
|
||||
}
|
||||
|
||||
if (("$CurrentSingleStackRecordv4" != "$CurrentIPv4address" ) && \
|
||||
([:typeof [:toip "$CurrentIPv4address"]] = "ip")) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* '$CurrentSingleStackIPv4RecordName' needs to update the IPv4-(A)-record";
|
||||
|
||||
}
|
||||
|
||||
:set $UpdateDNS "true";
|
||||
:set $UpdateCurrentSingleStackRecordv4 "true";
|
||||
|
||||
}
|
||||
|
||||
if (("$CurrentSingleStackRecordv6" != "$CurrentIPv6address" ) && \
|
||||
([:typeof [:toip6 "$CurrentIPv6address"]] = "ip6")) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* '$CurrentSingleStackIPv6RecordName' needs to update the IPv6-(AAAA)-record";
|
||||
|
||||
}
|
||||
|
||||
:set $UpdateDNS "true";
|
||||
:set $UpdateCurrentSingleStackRecordv6 "true";
|
||||
|
||||
}
|
||||
|
||||
if (("$CurrentTXTRecordIPv6Prefix" != "$CurrentIPv6prefix" ) && \
|
||||
# The following trick/workaround for the check was recomended by forum-sources:
|
||||
([:typeof ([[:parse "return $CurrentIPv6prefix"]])] = "ip6-prefix")) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* '$CurrentTXTRecordIPv6PrefixName' needs to update the prefix-(TXT)-record";
|
||||
|
||||
}
|
||||
|
||||
:set $UpdateDNS "true";
|
||||
:set $UpdateCurrentTXTRecordIPv6Prefix "true";
|
||||
|
||||
}
|
||||
|
||||
:put "";
|
||||
|
||||
|
||||
|
||||
# UPDATE INFORMATION
|
||||
|
||||
if ("$UpdateDNS" != "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "No DNS-updates-nescessary... everything is aye-ok!"
|
||||
:put "";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "";
|
||||
:put "Debug: Updating DNS-information";
|
||||
:put "###############################";
|
||||
:put "";
|
||||
}
|
||||
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "* Attempting to authenticate against '$($CONFIG->"IpaServer")' as user '$($CONFIG->"IpaUser")'";
|
||||
}
|
||||
|
||||
:local IPACookie [$GetIPACookie $CONFIG];
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
|
||||
:put "";
|
||||
:put "* The following cookie was recived:";
|
||||
:put "- '$IPACookie'";
|
||||
:put "";
|
||||
}
|
||||
|
||||
|
||||
if ("$UpdateCurrentDualStackRecordv4" = "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* Attempting to update '$CurrentDualStackRecordName' IPv4-(A)-record with '$CurrentIPv4address' ";
|
||||
:put ""
|
||||
}
|
||||
|
||||
$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv4address $CurrentDualStackRecordName $CurrentIPv4address;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ("$UpdateCurrentDualStackRecordv6" = "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* Attempting to update '$CurrentDualStackRecordName' IPv6-(AAAA)-record with '$CurrentIPv6address' ";
|
||||
:put ""
|
||||
}
|
||||
|
||||
$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv6address $CurrentDualStackRecordName $CurrentIPv6address;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ("$UpdateCurrentSingleStackRecordv4" = "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* Attempting to update '$CurrentSingleStackIPv4RecordName' IPv4-(A)-record with '$CurrentIPv4address' ";
|
||||
:put ""
|
||||
}
|
||||
|
||||
$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv4address $CurrentSingleStackIPv4RecordName $CurrentIPv4address;
|
||||
|
||||
}
|
||||
|
||||
if ("$UpdateCurrentSingleStackRecordv6" = "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* Attempting to update '$CurrentSingleStackIPv6RecordName' IPv4-(A)-record with '$CurrentIPv6address' ";
|
||||
:put ""
|
||||
}
|
||||
|
||||
$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv6address $CurrentSingleStackIPv6RecordName $CurrentIPv6address;
|
||||
|
||||
}
|
||||
|
||||
if ("$UpdateCurrentTXTRecordIPv6Prefix" = "true" ) do {
|
||||
|
||||
:if ( "$($CONFIG->"Debug")" = "true") do={
|
||||
:put "* Attempting to update '$CurrentTXTRecordIPv6PrefixName' prefix-(TXT)-record with '$CurrentIPv6prefix' ";
|
||||
:put ""
|
||||
}
|
||||
|
||||
$UpdateDynamicDNSRecord $CONFIG $IPACookie ipv6prefix $CurrentTXTRecordIPv6PrefixName $CurrentIPv6prefix;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue