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

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.

Related

WSL resolver need to resolve both internally and externally

I was unable to ping internal hosts.
I created an /etc/resolv.conf file in the form
nameserver internal
nameserver internal
search internal.mycomp.com mycomp.com
This worked perfectly for resolving internal host names.
However, ping www.google.com or ping www.ubuntu.com would now fail.
So, sudo apt-get would also fail.
I added opendns to resolv.conf
nameserver opendns
nameserver internal
nameserver internal
search internal.mycomp.com mycomp.com
Now ping www.ubuntu.com works, but internal resolution fails.
It would be nice to have both internal and external DNS working simultaneously.

How do I make dig use a source IP other than localhost while querying a DNS server running locally on my machine?

I am trying to run a coredns plugin https://github.com/coredns/demo that returns 1.1.1.1 for 172.0.0.0/8 or 127.0.0.0/8 and 8.8.8.8 for everything else.
I run the binary and try to make a request from dig using dig example.org #localhost -p1053 +short which returns 1.1.1.1 since the request is sent from localhost
Is there anyway I can send a request from dig to coredns that it might look like to the DNS server that it is sent from another IP and it will return 8.8.8.8 instead?
From dig manual:
-b address[#port]
Set the source IP address of the query. The address must be a valid address on one of the host's network interfaces, or "0.0.0.0" or "::". An optional port may be
specified by appending "#<port>"
Otherwise, if the server supports ECS (EDNS Client Subnet) you can use dig option +subnet=addr to give it to the server and see how its reply changes.

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.

URL with hostname does not work but works with IP address

I am working on RHEL 6.3, the IP address of this server is 172.xxx.xxx.xx and hostname is build01.xxx.com
I have a DNS entries of client server, I have configured that in /etc/sysconfig/network-scripts/ifcfg-eth0 and in /etc/resolv.conf
[root#build01 ~]# cat /etc/resolv.conf
search 100.xxx.x
nameserver 203.xxx.xxx.xxx ##Primary DNS
nameserver 203.xxx.xxx.xxx ###Secondary DNS
[root#build01 etc]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
172.xxx .xxx.xx build01.xxx.com build01
[root#build01 ~]# hostname
build01.xxxx.com
My issue is when I hit the URL with hostname(buil01.xxx.in) it does not work, but it works with IP (172.xxx.xxx.xx)
This is the error which i get in browser if I type hostname
Host Not Found
**DNS error (the host name of the page you are looking for does not exist) or Server did not accept the connection.
Please check that the host name has been spelled correctly.**
Internet works in this machine only issue is with hostname
Please help me what I am missing to configure
Thanks
Roopa
The search line in resolv.conf should list the local domain. So change:
search 100.xxx.x
to:
search xxx.com
Actually you should also change search to domain. For more information have a look at man resolv.conf.

Linux centos : ping displays unknown host for any domain name

Ping displays unknown host for any domain name.
It worked before this time true!!
Ping works for ip address but fails for domain names.
Can any one help me?
Check what's in /etc/resolv.conf.
If there is no "nameserver" specified, you have to do that in order to resolve domains.
Example:
nameserver dns1.domainname.com
nameserver dns2.domainname.com
or you can use Google's public DNS servers:
nameserver 8.8.8.8
nameserver 8.8.4.4
(1) edit /etc/resolv.conf, add
nameserver dns1.domainname.com
nameserver dns2.domainname.com
(2) another reason may due to /etc/nsswitch.conf
add dns in the hosts: xxx

Resources