I have an issue with my one Internet Provider. Internet traffic is passed through web proxy so the web proxy IP is passed to dyndns when trying get ip address.
For this reason, i need to get the ip address of the active interface and send that to dyndns. I have re-worked the script below and it works, with only one issue.
The IP Address is set to xxx.xxx.xxx.xxx/16. When this address is sent to dyndns, it fails as the formatting is incorrect, so dyndns then reads the ip address of in the header of the html packet, again, this is of the web proxy.
my solution is to strip the subnet and send the ipaddress only to dyndns.
Full Script
Code: Select all
# Define User Variables
:global ddnsuser "USERNAME"
:global ddnspass "PASSWORD"
:global ddnshost "DNS.HOST"
# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = "nothing" ) do={ :global ddnslastip "0" }
:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version] )
# Define Local Variables
:local int
# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int gateway]
}
}
# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = "nothing" ) do={
:log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DynDNS: Sending UPDATE!"
:local str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser \
password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
:delay 1
:local str [/file find name="DynDNS.$ddnshost"];
/file remove $str
:global ddnslastip $ddnsip
}
}
Code: Select all
:local str "/nic/update?hostname=$ddnshost&myip=$[b]ddnsip[/b]&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
Code: Select all
:global ddnssendip
Code: Select all
for i from=( [:len $ddnsip] - 1) to=0 do={ :if ( [:pick $ddnsip $i] = "/") do={ :put [:pick $ddnsip 0 $i]}}
please help with this last part.