How to configure recursive query in bind9 like dnsmasq? - dns

I can configure recursive query to 8.8.8.8 in dnsmasq with one line:
server=/#/8.8.8.8
Is there any configuration like dnsmasq in bind9 to make recursive query? Or does bind9 support this feature?

Related

Configuration of dnsmasq which allows to append a domain `search` to /etc/resolv.conf

Lets's look at following /etc/resolv.conf at client side:
# Generated by NetworkManager
search reddog.microsoft.com
nameserver 10.7.1.53
An 10.7.1.53 address is address of dnsmasq server. Is it possible to configure dnsmasq in such way that client of dnsmasq add some search domain ? I mean:
# Generated by NetworkManager
search reddog.microsoft.com my.domain.com
nameserver 10.7.1.53

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.

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.

receive all public hostnames in a bind (linux) server

I need to save all public hostnames, that usually can be detected with a dns query, in my dns server (bind9 in a kubuntu distribution), and after I need to open this list to elaborate it in a c++ program.
How is it possible to do this saving operation? Thanks a lot!
You can use host or dig command to run axfr query and redirect output to file:
host -t axfr yourdomain.com > records.txt
or
dig yourdomain.com axfr > records.txt
You can do this directly in dns server or any other host that has Bind's permission to do so.
Note that you have to have tcp port 53 open to your dns server if you use external host to run query.

Resources