admin管理员组

文章数量:1401658

is any way, how i can get TXT record from specific domain name via JavaScript in browser ?

Because we use anycast network, we need info, what node is requested from user location and show on the website. Because nodes has no websever, any relevant information is in TXT record of specific domain name.

is any way, how i can get TXT record from specific domain name via JavaScript in browser ?

Because we use anycast network, we need info, what node is requested from user location and show on the website. Because nodes has no websever, any relevant information is in TXT record of specific domain name.

Share Improve this question asked Aug 23, 2018 at 16:21 GransyGransy 1412 silver badges5 bronze badges 5
  • 1 I don't think there's any way to do a DNS lookup directly from the browser. Write a server script to do it, and call it with AJAX. – Barmar Commented Aug 23, 2018 at 16:25
  • Looks like Google has a public DNS API: developers.google./speed/public-dns/docs/dns-over-https – Barmar Commented Aug 23, 2018 at 16:26
  • @Barmar server-side script or any API is not possible use, because it will return responses in servers. It can be pletelly different than client responses, because server have another anycast node near. – Gransy Commented Aug 23, 2018 at 16:30
  • Firefox 60 or up has resolve: developer.mozilla/en-US/docs/Mozilla/Add-ons/WebExtensions/… but you do not seem to be able to choose the type. So you could in some way implement your idea (if I understood correctly), just do not use TXT but create a specific somesignal.example. A or AAAA record that will give a specific IP address, which has no real meaning except for your application. This could give you ideas too: security.stackexchange./questions/129917/… That is a standard trick. – Patrick Mevzek Commented Aug 23, 2018 at 17:48
  • check stackoverflow./questions/102605/… – Amir Forsati Commented Aug 23, 2018 at 17:51
Add a ment  | 

1 Answer 1

Reset to default 5

Note: this answer uses proprietary APIs. See RFC 8484 for the actual DNS-over-HTTPS specification.


Lots of stuff isn't possible with JavaScript in the average browser. I'm 97% certain that this is one of them. What you could do is write a small script on your server that does this lookup, or use ActiveX, Flash or Java to run nslookup on the client machine.

You could also use Cloudflare's DNS over HTTPS for this purpose. (Other DNS over HTTPS providers exist.) It's the same as the server technique, except somebody else has already done it. See this webpage for full details, but here's an example request URL:

https://cloudflare-dns./dns-query?name=example.&type=TXT

Other DNS over HTTPS providers are available; curl maintains a list. I strongly remend running your own server, instead of using one of these providers, if at all possible – it's significantly better for your users' privacy.

本文标签: javascriptHow to get TXT record from DNS in browser via JSStack Overflow