WSL resolver need to resolve both internally and externally - dns

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.

Related

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.

How to set DNS servers manually?

How do I exclude DNS from the DHCP lease request on a Raspberry Pi?
I tried updating /etc/resolv.conf but it's reset after a while.
Reason: I am on a home network, and the home router uses itself as the DNS server, but the router's DNS service isn't working properly sometimes.
Most of the answers didn't work for me, but I found that this worked:
sudo vi /etc/dhcpcd.conf
Added a line (note that there is no comma):
static domain_name_servers=8.8.8.8 8.8.4.4
And unplugged and replugged my ethernet cable, which updates the resolver...
cat /etc/resolv.conf
Now shows:
# Generated by resolvconf
domain example.com
nameserver 8.8.8.8
nameserver 8.8.4.4
This also a better way to fix the problem where changes to /etc/resolv.conf are lost on reboot.
I asume the problem is, that the dhcpclient is getting new information about DNS servers with every dhcp-renewal. Add this line into /etc/dhcp/dhclient.conf:
option domain-name-servers 192.168.1.8, 8.8.8.8, 8.8.4.4
Of course you should replace the ip-addresses with the ones from your demanded DNS server. Probably restart the according service.

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

host doing unnecessary dns lookup for localhost

I have a centOS system(embedded and has very binaries) with the following /etc/hosts.
$cat /etc/hosts
127.0.0.1 localhost localhost
Also the host is assigned a DNS server which returns some invalid IP for the domain name lookup of localhost. But I cannot avoid a connection to this DNS due to some network restrictions.
My question is, when I already have a valid /etc/hosts file why is the system querying the DNS for localhost? And how can I stop that?
Any help would be greatly appreciated.
Check that you have files listed before dns for the hosts entry in /etc/nsswitch.conf.
[me#home]$ grep "^hosts" /etc/nsswitch.conf
hosts: files dns
If dns comes first, then your system will always query DNS to resolve hostnames before falling back to /etc/hosts.

Resources