Skip to content

Add custom DNS records #975

Closed
Closed

Description

@pkramme

In raising this issue, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your issue:

How familiar are you with the codebase?:

  • [] 1 (very unfamiliar)
  • 2
  • [] 3
  • [] 4
  • [] 5
  • [] 6
  • [] 7
  • [] 8
  • [] 9
  • [] 10 (very familiar)

FEATURE REQUEST:
I'd like to add easy DNS entrees, so i can reach my local devices over them. Since hostnames are not working after switching DNS from router to pihole, this would be nice. I'm very sorry if i reposted this, i did not find it under open issues.

This template was created based on the work of udemy-dl.

Activity

  1. dschaper commented on Dec 9, 2016

    @dschaper
    Member

    Are you asking to use a custom upstream provider for your DNS server (in place of Google or OpenDNS for example) or are you asking about entering data into the Pi-hole's HOSTS file so that you can reach local machines by their short names?

  2. pkramme commented on Dec 9, 2016

    @pkramme
    Author

    Latter.

  3. AzureMarker commented on Dec 9, 2016

    @AzureMarker
    Contributor

    Add your hosts to your Pi-hole's /etc/hosts file.

  4. dschaper commented on Dec 9, 2016

    @dschaper
    Member

    Okay, I will pass that along as a feature request, it's possible to do now, if you use the Pi-hole's dnsmasq process as your DHCP server, but we need to work out a way to safely edit the /etc/hosts file and determine a process to present those options to the users. If the Pi-hole also acts as the DHCP server, then dnsmasq will automatically add the short name to the resolver's lookups but this would require disabling the DHCP server on the router and passing that function over to the Pi. It's a feature we are talking about, but we want to do it in a sane way that will hopefully avert the possibility of a user locking themselves out, :) If you'd like to open a Feature Request over on discourse then other users will be able to vote and comment on the idea.

  5. jannylund commented on Jan 18, 2017

    @jannylund

    @paulkramme an easy workaround for this is to set pihole to use your routers dns instead of google, then your local host config works as before.

  6. pkramme commented on Jan 18, 2017

    @pkramme
    Author
  7. MeganerdNL commented on Jan 30, 2017

    @MeganerdNL

    Edit the file /etc/dnsmasq.d/03-pihole-wildcard.conf

    Add entries like this:

    address=/printer.mydomain.com/192.168.2.9
    address=/babycam.mydomain.com/192.168.2.10

    This is working very well here. Don't forget to flush DNS on Windows machine when testing.
    You cannot enter these values in the webinterface, there only default values are possible (it's the wildcard option). Maybe it could be added to the webinterface.

  8. ldrrp commented on Feb 16, 2017

    @ldrrp
  9. pkramme commented on Feb 16, 2017

    @pkramme
    Author

    @ldrrp Wow! Thats great, hopefully it will boost this feature.

  10. MeganerdNL commented on Feb 20, 2017

    @MeganerdNL

    You can also make a new file in /etc/dnsmasq.d/ with .conf extentsion. All files in this directory are read by dnsmasq. You can add/map DNS entries just like I said in my previous post like this:

    address=/printer.lan/192.168.2.9
    address=/babycam.lan/192.168.2.10
    

    Again: it would be very nice if this was a feature of the web-gui.

  11. pkramme commented on Feb 20, 2017

    @pkramme
    Author

    I think i will write a program for this, i will link this here when im finished. Can i name the file whatever i want, like mom.conf?

  12. dschaper commented on Feb 20, 2017

    @dschaper
    Member

    Conf files are sourced lexicographically, so 01 first, but typically they are named with a number leading, so 99 would be sourced last, so a 50-mom.conf would be in the middle and can still be overridden. (dnsmasq will throw errors if commands are duplicated, but should be okay if they are appending.)

  13. pkramme commented on Feb 20, 2017

    @pkramme
    Author
  14. 21 remaining items

  15. Zixim commented on Apr 1, 2019

    @Zixim

    If you have the possibility to set pihole as your DHCP server, then you can assign hostnames to devices from the DHCP config page.

  16. hopeseekr commented on Jun 11, 2019

    @hopeseekr

    I'm much more interested in setting a custom DNS entry for https://archive.is/, as seeing how they actively block CloudFlare DNS from querying them (they point to 127.0.0.4).

  17. dschaper commented on Jun 11, 2019

    @dschaper
    Member

    Is there anything currently stopping you from doing so?

  18. changed the title [-]Add custom DNS entrees[/-] [+]Add custom DNS entries[/+] on Jun 11, 2019
  19. changed the title [-]Add custom DNS entries[/-] [+]Add custom DNS records[/+] on Jun 11, 2019
  20. Ilshidur commented on Aug 23, 2019

    @Ilshidur

    There's CLI command for this :

    pihole -a hostrecord subdomain.example.com 1.2.3.4

    EDIT: do not use this, this will only change the hostname, if I understand correctly.

  21. makew0rld commented on Oct 30, 2019

    @makew0rld

    @Ilshidur Are there commands to list or remove records? I can't find them.

  22. Zixim commented on Oct 31, 2019

    @Zixim

    add : pihole -a hostrecord home.mydomain.de 192.168.1.10

    list : grep 'host-record' /etc/dnsmasq.d/01-pihole.conf
    But listing seems of little use, since you can add just the 1 hostrecord.

    remove : pihole -a hostrecord

  23. makew0rld commented on Oct 31, 2019

    @makew0rld

    Oh you can only add one? I didn't realize. Thanks!

  24. Zixim commented on Oct 31, 2019

    @Zixim

    at present, the cleanest way to add your own dns records would be :

    • make sure that /etc/dnsmasq.conf contains the line : conf-dir=/etc/dnsmasq.d
    • create a file in /etc/dnsmasq.d to store your custom dns records :
    $ ls -lha /etc/dnsmasq.d
    total 57K
    drwxr-xr-x  2 root root    7 Oct 31 10:52 .
    drwxr-xr-x 95 root root  187 Oct 29 10:27 ..
    -rw-r--r--  1 root root 1.6K Oct 31 10:52 01-pihole.conf
    -rw-r--r--  1 root root  488 Oct 27 11:45 02-pihole-dhcp.conf
    -rw-r--r--  1 root root 1.9K Aug 13 15:57 04-pihole-static-dhcp.conf
    -rw-r--r--  1 root root   47 Jun 22 11:54 98-hostrecords-dns.conf
    -rw-r--r--  1 root root  175 Aug 13 15:59 99-reservations-dhcp.conf
    $ cat 98-hostrecords-dns.conf
    host-record=mydomain.duckdns.org,192.168.1.10
    

    Add as many host-record lines as you like.

    • Don't forget to pihole restartdns if you add/remove domains.
  25. eitch commented on Nov 27, 2019

    @eitch

    I tried this on my pihole, and somehow the DNS system didn't want to start anymore. I have no added the records to

    /etc/pihole/local.list
    

    and now it works as expected

  26. Zixim commented on Nov 27, 2019

    @Zixim

    @eitch Don't use local.list , it is a system generated file and will get overwritten sooner or later by updates & such.

  27. eitch commented on Nov 27, 2019

    @eitch

    @Zixim then there is a bug, when using the host-records directive the pi-hole manager says the DNS service does not start, which i can see as i can't lookup any addresses anymore?

  28. Zixim commented on Nov 27, 2019

    @Zixim

    did you perhaps edit the .conf file with a windows text editor ?
    dnsmasq --test will do basic syntax checks on the config files

    EDIT : hmm...dnsmasq --test doesn't work on pihole. Check syslog for errors ?
    EDIT EDIT : pihole-FTL dnsmasq-test is the right syntax for modern Piholes.

  29. eitch commented on Nov 27, 2019

    @eitch

    Weird... i just tried again and now it works. I prepared to check all logs, FTL, pihole, daemon.log etc. but no error and it works as expected. I only move back the file which i had given the ending .bck to 98-hostrecords-dns.conf and performed a restart. Thanks anyhow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions