Community discussions

MikroTik App
 
efaden
Forum Guru
Forum Guru
Topic Author
Posts: 1708
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

IPv6 Version of Resolve?

Tue Jul 30, 2013 7:08 pm

Is there one to do IPv6 DNS queries?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: IPv6 Version of Resolve?

Tue Jul 30, 2013 7:16 pm

AFAIK, if the remote site does not have an IPv4 address, but has an IPv6 one, the IPv6 is used. Haven't actually tried it though.

But if you want to force/prefer IPv6... yeah, I don't think there's such an option (yet?).
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: IPv6 Version of Resolve?

Thu Aug 01, 2013 5:07 pm

as Boen_robot explained:

:resolve command will return ipv4 address (A record) if that exists, if not, then ipv6 address will be returned (AAAA record)

in some places you have to explicitly use :resolve to be able to use domain name resolution:
/ping [:resolve ipv6.google.com]
will ping ipv6 address.
 
Russian
just joined
Posts: 9
Joined: Wed Jun 12, 2013 10:03 pm
Location: South Africa
Contact:

Re: IPv6 Version of Resolve?

Wed Aug 07, 2013 4:24 pm

Hi,

Not sure how Linux handles this, but on windows IPv6 is resolved first then ipv4 (aka, if there is a v6 route it will use that first)

Maybe make a option on the router to force the one or the other?

Personally I prefer the v4 atm, as my v6 range is over a slooooow link
 
niammuddin
just joined
Posts: 7
Joined: Sun Aug 26, 2018 2:03 am

Re: IPv6 Version of Resolve?

Fri Dec 10, 2021 11:11 pm

as Boen_robot explained:

:resolve command will return ipv4 address (A record) if that exists, if not, then ipv6 address will be returned (AAAA record)

in some places you have to explicitly use :resolve to be able to use domain name resolution:
/ping [:resolve ipv6.google.com]
will ping ipv6 address.
maybe add feature for specific attribute only ipv6/ipv4
because under certain conditions we need it, for example in 1 domain there are 2 records, the first is IPv4 and the second is IPv6.
whereas I want to display the result of ipv6
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3255
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: IPv6 Version of Resolve?

Tue Dec 14, 2021 1:24 am

as Boen_robot explained:

:resolve command will return ipv4 address (A record) if that exists, if not, then ipv6 address will be returned (AAAA record)

maybe add feature for specific attribute only ipv6/ipv4
I just ran into a similar issue. :resolve does NOT support some kinda of type= option. I wanted use :resolve for TXT record, and CLI tells me it take an options. But if they add a DNS record type option, like type=AAAA, it would solve the IPv6 issue as well as well as my TXT lookups.

So +1 from me.
 
User avatar
colinardo
just joined
Posts: 18
Joined: Sun Jan 08, 2017 9:02 pm

Re: IPv6 Version of Resolve?

Fri Dec 30, 2022 4:38 pm

Hi folks.
You can use a firewall address list as a workaround for this.

Example:
 /ipv6 firewall address-list {
     add list=google-dns address=dns.google.com
     :delay 1
     :foreach ip in=[find list=google-dns && dynamic] do={:put [get $ip address]}
 }
Outputs:
2001:4860:4860::8844/128
2001:4860:4860::8888/128
You could also build a function for this and load it on router start to be able to use it later on (this also strips the subnetmask /128 from the ip and returns an array if there are multiple records)
# define global function to resolve IPv6 DNS Names to IPs
:global resolveipv6 do={
    :local result [:toarray ""]    
    :local maxwait 5
    :local cnt 0
    :local listname "tmp-resolve$cnt"
    /ipv6 firewall address-list {
        :do {
            :while ([:len [find list=$listname]] >0) do={
                :set cnt ($cnt + 1)
                :set listname "tmp-resolve$cnt"
            }
            :set cnt 0
            add list=$listname address=$1
            :while ([find list=$listname && dynamic] = "" && $cnt < $maxwait) do={:delay 1;:set cnt ($cnt +1)}
            :foreach i in=[find list=$listname && dynamic] do={
                 :local rawip [get $i address]
                 :set result ($result, [:pick $rawip 0 [:find $rawip "/"]])
            }
            remove [find list=$listname && !dynamic]
        }
     }
    :return $result
}
# use new global function (output to console)
:put [$resolveipv6 "dns.google.com"]

# use new global function (save to variable, returns an array)
:local myvar [$resolveipv6 "dns.google.com"]
# edit: fixed typo

Regards
@colinardo
Last edited by colinardo on Sun Jan 01, 2023 3:47 am, edited 6 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: IPv6 Version of Resolve?

Sat Dec 31, 2022 6:20 pm

You can use a firewall address list as a workaround for this.

Nice, but check syntax errors, like missing : before "tosomething" and on-horror


Reworked version:
# define global function to resolve IPv6 DNS Names to IPs
:global resolveipv6 do={
    :local maxwait 5
    :local search  [:toarray ""]
    :local result  [:toarray ""]
    /ipv6 firewall address-list
    remove [find where list=tmp-resolve and address=$1]
    add list=tmp-resolve address=$1
    :local cnt 0
    :do {
        :delay 1s
        :set cnt ($cnt +1)
        :set search [find where list=tmp-resolve and dynamic=yes]
    } while=(([:len $search] = 0) and ($cnt < $maxwait))
    :foreach i in=$search do={
        :local tmpadd [get $i address]
        :set result ($result, [:pick $tmpadd 0 [:find $tmpadd "/"]])
    }
    remove [find where list=tmp-resolve and dynamic=no]
    :return $result
}

# use new global function (output to console)
:put [$resolveipv6 "dns.google.com"]

# use new global function (save to variable, returns an array)
{
:local myvar [$resolveipv6 "dns.cloudflare.com"]
:put $myvar
}
 
ilium007
Member Candidate
Member Candidate
Posts: 206
Joined: Sun Jan 31, 2010 9:58 am
Location: Newcastle, Australia

Re: IPv6 Version of Resolve?

Sun Jan 14, 2024 10:34 am

This was first raised over 10 years ago. Where can we put it in a feature request list. Ridiculous that it hasn't been implemented.

Used this and it works but its a messy kludge:

https://administrator.de/en/mikrotik-sc ... 10821.html

MOD EDIT: credit where credit is due: author of the script is rextended. Not the one showing it on the webpage.

Who is online

Users browsing this forum: No registered users and 16 guests