How to set dns server in node.js resolve query? - node.js

I'm trying to set Google DNS server 8.8.8.8 in Node.js resolve query.
What is the correct way to do so? In command line usually we can do the following:
$ nslookup stackoverflow.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: stackoverflow.com
Address: 151.101.1.69
Address: 151.101.65.69
Address: 151.101.129.69
Address: 151.101.193.69
But its not quite clear how to make same approach in Node.js
require('dns').resolve('stackoverflow.com', function (err, addresses) {
console.log(err, addresses);
});
// => null [ '151.101.1.69', '151.101.65.69', '151.101.129.69', '151.101.193.69' ]

From nodejs doc: https://nodejs.org/api/dns.html#dns_dns_setservers_servers
dns.setServers([
'4.4.4.4',
'[2001:4860:4860::8888]',
]);

You can use following command:
npm config set dns 8.8.8.8

Related

Unbound does not give a record of the reverse zone

I have a bunch of unbound + nsd, nsd has the reverse zones prescribed and it gives them normally:
nslookup 91.232.162.225 127.0.0.53
225.162.232.91.in-addr.arpa name = mysite.com.
And there are two configs in unbound for addresses on the local subnet:
server:
local-zone: "10.in-addr.arpa.
stub-zone:
name: "10.in-addr.arpa.
stub-addr: 127.0.0.53
and external addresses:
server:
local-zone: "91.in-addr.arpa.
stub-zone:
name: "91.in-addr.arpa.
stub-addr: 127.0.0.53
Everything is fine with local addresses, but for some reason it doesn't work with external addresses
nslookup 91.232.162.225
;; Got SERVFAIL reply from 91.232.162.225, trying next server
** server can't find 10.162.232.91.in-addr.arpa: NXDOMAIN
Maybe someone has faced with this, how to spell stub-zone for external ip correctly.
Thanks

Can not open Logrocket Dashboard when AdGuard DNS used

I setup my WIFI network router with AdGuard DNS to filter out Ads. Works great I even can open Linked in from Russia without VPN. But now I can not access app.logrocket.com
How can I access the app.logrocket.com?
The issue was the AdGuard DNS itself. The "Default" and "Family" DNS consider the logrocket as Ads source. To fix that you should use "Non-filtering" DNS servers
This is answer from "Default" AdGuard DNS
nslookup logrocket.com 94.140.14.14
Server: 94.140.14.14
Address: 94.140.14.14#53
Non-authoritative answer:
Name: logrocket.com
Address: 0.0.0.0
This is answer from "Non-filtering" AdGuard DNS
nslookup logrocket.com 94.140.14.141
Server: 94.140.14.141
Address: 94.140.14.141#53
Non-authoritative answer:
Name: logrocket.com
Address: 104.26.9.185
Name: logrocket.com
Address: 104.26.8.185
Name: logrocket.com
Address: 172.67.75.120

nslookup reported "can't resolve '(null)': Name does not resolve" though it successfully resolved the DNS names

I am on ubuntu, and I am running a docker default bridge network. I have containerized versions of zookeeper, kafka, and an app that I wrote that talks to kafka.
I do a:
docker exec -it <my-app id> /bin/bash
Then inside my app's container I run nslookup kafka
/go # nslookup schmafka
nslookup: can't resolve '(null)': Name does not resolve
Name: schmafka
Address 1: 172.20.0.8 docker_kafka_1.docker_default
I do not understand why I get the output "can't resolve '(null)'" and then I get the expected ip address printed out later. I tried to google nslookup and this output message but I cannot figure why this happens.
My /etc/resolv.conf file looks like this:
/go # cat /etc/resolv.conf
search valhalla.local valhalla v
nameserver 127.0.0.11
options ndots:0
This is a bug/oddity in nslookup. The "can't resolve" message is actually about the DNS server in use, not the site you are trying to look up.
For example this query (which tells nslookup to lookup google.com using the 8.8.8.8 DNS server) has no error message:
nslookup google.com 8.8.8.8
Server: 8.8.8.8
Address 1: 8.8.8.8 dns.google
Name: google.com
Address 1: 172.217.164.110 sfo03s18-in-f14.1e100.net
Address 2: 2607:f8b0:4005:80b::200e sfo03s18-in-x0e.1e100.net
But this query (in which the DNS server is "null") does show the "error":
UAP-AC-LR1-BZ.v4.0.42# nslookup google.com
nslookup: can't resolve '(null)': Name does not resolve
Name: google.com
Address 1: 172.217.164.110 sfo03s18-in-f14.1e100.net
Address 2: 2607:f8b0:4005:80b::200e sfo03s18-in-x0e.1e100.net
Admittedly this is misleading/confusing, and really should be fixed in nslookup.

Do I need anything else other than an SRV record to make it work?

I'm trying to setup an SRV record to let users connect to a game server.
The server uses the port 27016 UDP and TCP (actually TCP is used just by steam) so I have created two SRV records:
_ARKSRV._tcp.join.domain.tld. SRV domain.tld.
_ARKSRV._udp.join.domain.tld. SRV domain.tld.
But when I try to ping it or use nslookup I get:
~$ ping join.domain.tld
ping: cannot resolve join.domain.tld: Unknown host
~$ nslookup -q=SRV _ARKSRV._tcp.join.domain.tld
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find _ARKSRV._tcp.domain.tld: NXDOMAIN
I'm wondering if I need to create even an A record to make it work or what.
your zone records:
_ARKSRV._tcp.join.domain.tld. SRV domain.tld.
_ARKSRV._udp.join.domain.tld. SRV domain.tld.
do not match your lookup:
~$ nslookup -q=SRV _ARKSRV._tcp.domain.tld
Your SRV record also appears to have an incorrect syntax. Part of the reason to use an SRV record is so that you can specify port. Reference link

slow or timeout of dns resolving inside docker

On host machine, it's very fast to lookup a domain. But inside docker container, it's much
slower and sometimes timeout.
The host machine is a virtual host, and it's dns server address is 127.0.0.1 (weird but true). So I've tried to modify /etc/resolv.conf inside container and set the dns server to be 172.x (host's address). As a result, I didn't see any good effect.
I've also tried to set the container's dns server to be a self-built one (101.x), but still, it's slow to look up a domain. Another weird thing is that ping 101.x is very fast.
I'm confused about this phenomenon, anyone can explain and help?
I am not sure of why resolving DNS is slow in the containers, but I have procedure which I follow to resolve the DNS in the docker containers.
To verify DNS resolution issue:
# docker run busybox nslookup google.com
Server: 8.8.8.8
Address 1: 8.8.8.8
nslookup: can't resolve 'google.com'
Find out the DNS server used in your machine :
# nm-tool |grep DNS
DNS: 172.24.100.50
DNS: 10.1.100.50
Run it again using DNS IP found in the above step which resolves the DNS issue:
# docker run --dns 172.24.100.50 busybox nslookup google.com
Server: 172.24.100.50
Address 1: 172.24.100.50 indc01.radisys.com
Name: google.com
Address 1: 2607:f8b0:4009:80c::200e ord36s01-in-x0e.1e100.net
Address 2: 172.217.4.110 ord36s04-in-f14.1e100.net
To resolve it permanently add the following content as below to a new file:
root#labadmin-VirtualBox:/home/labadmin# cat /etc/docker/daemon.json
{
"dns" : ["172.24.100.50", "8.8.8.8"]
}
More info on Docker DNS configuration.
Restart the docker service and verify it again:
# docker run busybox nslookup google.com
Server: 172.24.100.50
Address 1: 172.24.100.50 indc01.radisys.com
Name: google.com
Address 1: 2607:f8b0:4009:801::200e ord30s31-in-x0e.1e100.net
Address 2: 172.217.4.238 ord30s31-in-f14.1e100.net
Check it by running the container:
# docker run -it e02e811dd08f
/ # ping google.com
PING google.com (172.217.4.238): 56 data bytes
64 bytes from 172.217.4.238: seq=0 ttl=47 time=251.506 ms
64 bytes from 172.217.4.238: seq=1 ttl=47 time=245.621 ms
Hope this helps.

Resources