Linux dhcp dhclient Mint Redhat Ubuntu Debian How To Use Local Domain DNS Server Instead of ISPs

If you are running a local DNS server like named/bind and don't want to use the ISP supplied DNS servers that are announced via a DHCP request (using dhclient) then the solution is simple.

The reason should be obvious, but normally running your own DNS server will provide a more reliable, and fast DNS response and you won't have to worry about filtering as much (unless your upstream filters or proxies outgoing DNS requests).

Edit /etc/dhcp/dhclient.conf

Add the following line, or in many cases you can find the line is there but just commented out with a #.  Uncomment it or add the line like below:

prepend domain-name-servers 127.0.0.1;

Need more DNS servers just add a comma after:

prepend domain-name-servers 127.0.0.1, 192.168.10.80;

Now when checking /etc/resolv.conf, you should see that the first DNS server is 127.0.0.1 and then whatever your ISP or LAN provided you with.

What if you want to define the ONLY DNS servers and not use anything from the ISP/DHCP Server

Instead of the "prepend" option, we can use "supersede" which will completely ignore all the DNS servers provided from the DHCP server. 

Add the following line, or in many cases you can find the line is there but just commented out with a #.  Uncomment it or add the line like below:

supersede domain-name-servers 127.0.0.1;

Just like the prepend option you can specify multiple DNS servers like this:

supersede domain-name-servers 127.0.0.1, 192.168.10.80;

Of course, keep in mind that if your local DNS fails or is not working or starting for any reason, that DNS requests will fail, which will generally cause many things to break.  It is probably wise to use a secondary, trusted DNS server on your LAN or on the public internet if possible.

Don't Forget To Disable systemd-resolved

On most GUI Linux's such as Ubuntu/Mint etc.. you will have systemd-resolved which has it's own listener on port 53 which forwards requests to the actual DNS server (eg. your ISP's).  This will conflict with your local listener (eg. bind/named).  If you want to use your localhost DNS successfully remember to disable systemd-resolved and stop the service or you will have broken DNS.

systemctl disable systemd-resolved

#remember to stop it too!

systemctl stop systemd-resolved

 


Tags:

linux, dhcp, dhclient, mint, redhat, ubuntu, debian, domain, dns, server, isps, bind, isp, supplied, servers, announced, via, reliable, filtering, upstream, filters, proxies, outgoing, requests, edit, etc, conf, commented, uncomment, prepend, resolv, lan, provided,

Latest Articles

  • How To Stop DNSMasq from listening on all IPs/Interfaces and allow only localhost
  • du - VAS Billing Subscriptions Hack/Scam MLPremiumSub Invascom Astromart Issues Complaint
  • Docker Swarm vs Kubernetes Comparison Guide
  • When is it time to leave your VPS/VDS Cloud Hosting Provider?
  • 2024 Buyer's Guide: How to Choose and Buy the Best VPS/VDS for Your Needs - Tips and Strategies
  • Postfix / sendmail config for DKIM, SPF and DMARC Tutorial Guide E-mail Delivery for Hotmail.com Gmail.com and More HowTo
  • Install Grafana on Linux Debian Ubuntu Tutorial Guide
  • How To Completely Disable ufw in Linux Ubuntu Mint Debian
  • System has not been booted with systemd as init system (PID 1). Can't operate. Failed to talk to init daemon. Ubuntu Debian Linux Solution Cannot reboot
  • Mint Ubuntu Linux Gnome Showing Home Directory on Desktop instead of Desktop Directory
  • vi vim not doing code highlighting E319: Sorry, the command is not available in this version solution
  • Proxmox How To Rename Node Hostname Fix Solution
  • Linux how to get list of all timezones on system Ubuntu
  • Proxmox install issue cannot see the buttons or install wrong / bad resolution cannot see the entire screen problem solution
  • configure.ac:75: error: possibly undefined macro: AC_PROG_LIBTOOL If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. solution
  • Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326. autoreconf: failed to run aclocal: No such file or directory solution
  • /bin/sh: autoreconf: command not found solution
  • glib-2.0 required to compile QEMU solution
  • How To Upgrade Debian 8,9,10 to Debian 12 Bookworm
  • Linux dhcp dhclient Mint Redhat Ubuntu Debian How To Use Local Domain DNS Server Instead of ISPs