IPv6 Version of Resolve?

Is there one to do IPv6 DNS queries?

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?).

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.

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

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

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

Nice, but check syntax errors, like missing : before “to_something_” 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
}

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-scripting-resolve-domain-to-ipv6-address-5151910821.html

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