Community discussions

MikroTik App
 
Goasler
just joined
Topic Author
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

[Script] Domain Name / DNS Name via nslookup on RB2011

Tue Nov 13, 2012 10:26 pm

Hello @ all.
Sorry for my bad English, but im from Germany.
Im new here and i need help with my new MikroTik RouterBoard RB2011US-2HnD-in.

If i type in windwos Command Console
nslookup 88.140..... 
then is the Answer:

pXXXXX.dip.t-dialin.net

I Search for a scipt that do follow:
Step 1: 
get my Current Ip (from File "dyndns.txt" or anything else; the file Contains "Current IP: 80.140..." from my DynDNS Script)
set my current IP Adress as: "$CurrentIP"

Step2:
nslookup $CurrentIP
set Answer as=$CurrentDomain 
/log info "My current DNS is: $CurrentDomain" (pXXX.dip.t-dialin.net)

Step3:
get to my  "T-Online" PPPoE Client and set a comment like= "My Domain is: $CurrentDomain"
I hope for answers.
Thank You.
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: [Script] Domain Name / DNS Name via nslookup on RB2011

Thu Nov 15, 2012 12:38 am

like this?


{
:local result [/file get dyndns.txt contents]
local resultlen [len $result]
local end [$resultlen +1]
local  tmp [find $result key=:]
local start ($tmp + 2)
local currentIP [:pick $result $start $end]
local currentdomain [resolve $currentIP]
/log info "My current DNS is: $currentdomain"
interface pppoe-client set comment="My Domain is: $currentdomain" [find ]
}
what is your script for dyndns update?
 
Goasler
just joined
Topic Author
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

Re: [Script] Domain Name / DNS Name via nslookup on RB2011

Fri Nov 16, 2012 8:10 pm

Thank you

my DynDNS Script is:
# Set needed variables
:local username "LOGINNAME"
:local password "PASSWORT"
:local hostname "XXX.dyndns.org"

:global dyndnsForce
:global previousIP 

# print some debug info
#:log info ("UpdateDynDNS: username = $username")
#:log info ("UpdateDynDNS: password = $password")
#:log info ("UpdateDynDNS: hostname = $hostname")
#:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:delay 1
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
#:log info "UpdateDynDNS: currentIP = $currentIP"
:log info "<<<<<< AKTUELLE IP: $currentIP >>>>>>"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
   :set dyndnsForce false
   :set previousIP $currentIP
   :log info "$currentIP or $previousIP"
   /tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
      src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
      dst-path="/dyndns.txt"
   :delay 1
   :local result [/file get dyndns.txt contents]
   :log info ("UpdateDynDNS: Dyndns update needed")
   :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
   :put ("Dyndns Update Result: ".$result)
} else={
#:log info ("UpdateDynDNS: No dyndns update needed")
}
 
Goasler
just joined
Topic Author
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

Re: [Script] Domain Name / DNS Name via nslookup on RB2011

Fri Nov 16, 2012 8:20 pm

Sorry but the script is not working

MikroTik RB2011US-2HnD-in Version: 5.21

Content of "dyndns.txt"
good 80.142.205.197
Content of "dyndns.checkip.html":
<html><head><title>Current IP Check</title></head><body>Current IP Address: 80.142.205.197</body></html>
 
Goasler
just joined
Topic Author
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

Re: [Script][SOLVED] Domain Name / DNS Name via nslookup

Fri Nov 16, 2012 10:08 pm

I have solved it differently, but many thanks
 
Goasler
just joined
Topic Author
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

Re: [Script] Domain Name / DNS Name via nslookup on RB2011

Fri Nov 16, 2012 10:09 pm

~~~ Closed ~~~

Who is online

Users browsing this forum: GoogleOther [Bot] and 8 guests