Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom DNS records #975

Closed
pkramme opened this issue Dec 9, 2016 · 41 comments
Closed

Add custom DNS records #975

pkramme opened this issue Dec 9, 2016 · 41 comments
Assignees

Comments

@pkramme
Copy link

@pkramme pkramme commented Dec 9, 2016

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.

@dschaper
Copy link
Member

@dschaper dschaper commented Dec 9, 2016

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?

@pkramme
Copy link
Author

@pkramme pkramme commented Dec 9, 2016

Latter.

@AzureMarker
Copy link
Contributor

@AzureMarker AzureMarker commented Dec 9, 2016

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

@dschaper
Copy link
Member

@dschaper dschaper commented Dec 9, 2016

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.

@jannylund
Copy link

@jannylund jannylund commented Jan 18, 2017

@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.

@pkramme
Copy link
Author

@pkramme pkramme commented Jan 18, 2017

@MeganerdNL
Copy link

@MeganerdNL MeganerdNL commented Jan 30, 2017

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.

@pkramme
Copy link
Author

@pkramme pkramme commented Feb 16, 2017

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

@MeganerdNL
Copy link

@MeganerdNL MeganerdNL commented Feb 20, 2017

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.

@pkramme
Copy link
Author

@pkramme pkramme commented Feb 20, 2017

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?

@dschaper
Copy link
Member

@dschaper dschaper commented Feb 20, 2017

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.)

@pkramme
Copy link
Author

@pkramme pkramme commented Feb 20, 2017

@DL6ER
Copy link
Member

@DL6ER DL6ER commented Feb 20, 2017

Unfortunately, I don't have much time this week, but I will look into this issue. I don't need this as I'm using the Pi-hole DHCP server, which already adds this functionality.

@pkramme
Copy link
Author

@pkramme pkramme commented Feb 20, 2017

I created a repository

@ldrrp
Copy link

@ldrrp ldrrp commented Feb 20, 2017

@paulkramme its probably better to add it to the web interface since it is protected by a login.

@pkramme
Copy link
Author

@pkramme pkramme commented Feb 20, 2017

@DL6ER DL6ER self-assigned this Mar 3, 2017
@tobiastom
Copy link

@tobiastom tobiastom commented May 22, 2017

Just as a small addition, this might also be a nice feature to configure specific addresses to a given localised IP, this would solve some problems with geo location based IPs.

@AzureMarker
Copy link
Contributor

@AzureMarker AzureMarker commented May 22, 2017

It looks like this feature has been implemented: #1266

@tobiastom
Copy link

@tobiastom tobiastom commented May 23, 2017

This is awesome. Somehow it looks all documentation is only available inside the pull request.

Thank you @Mcat12 for the update!

@mikegleasonjr
Copy link

@mikegleasonjr mikegleasonjr commented Oct 24, 2017

For those wondering how to add multiple entries, add your entries to /etc/hosts then $ pihole restartdns

@dadatuputi
Copy link

@dadatuputi dadatuputi commented Jan 24, 2018

The 'solutions' here don't really do anything that editing the hosts file doesn't do already, correct? I'd love a DNS entry page in the WebUI for this purpose. I can take a crack at adding the feature if there's a chance my pull request would be approved.

@Comodore125
Copy link

@Comodore125 Comodore125 commented Jan 28, 2018

Very unfortunate to see this closed.

@dschaper
Copy link
Member

@dschaper dschaper commented Jan 28, 2018

It's been implemented in #1266 hence it was closed.

@dadatuputi
Copy link

@dadatuputi dadatuputi commented Jan 28, 2018

@dschaper That merge requests allows for a single DNS entry, whereas this feature request is for multiple entries. A good solution would allow editing them from the WebUI, imo.

@dschaper
Copy link
Member

@dschaper dschaper commented Jan 29, 2018

We can only do so much with the volunteer time we have, if you have a PR that you'd like to submit or code suggestions then we can look at implementing it. There are a lot of feature requests and none of the developers work on this full time. I appreciate the thumbs down votes, they help prioritize what we should work on next.

@pi-hole pi-hole deleted a comment from dschaper Jan 30, 2018
@PromoFaux PromoFaux changed the title Add custom DNS entrees Add custom DNS entrees [$10 awarded] Mar 5, 2018
@PromoFaux PromoFaux changed the title Add custom DNS entrees [$10 awarded] Add custom DNS entrees Apr 10, 2018
@hopeseekr
Copy link

@hopeseekr hopeseekr commented Mar 31, 2019

So it's safe to say that 15 months later nothing has been accomplished?

@DL6ER
Copy link
Member

@DL6ER DL6ER commented Mar 31, 2019

So it's safe to say that 15 months later nothing has been accomplished?

As there hasn't been a pull request referencing this issue ticket, I assume the answer is Yes.

@Zixim
Copy link

@Zixim Zixim commented Apr 1, 2019

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

@hopeseekr
Copy link

@hopeseekr hopeseekr commented Jun 11, 2019

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).

@dschaper
Copy link
Member

@dschaper dschaper commented Jun 11, 2019

Is there anything currently stopping you from doing so?

@pkramme pkramme changed the title Add custom DNS entrees Add custom DNS entries Jun 11, 2019
@pkramme pkramme changed the title Add custom DNS entries Add custom DNS records Jun 11, 2019
@Ilshidur
Copy link

@Ilshidur Ilshidur commented Aug 23, 2019

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.

@makeworld-the-better-one

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

@Zixim
Copy link

@Zixim Zixim commented Oct 31, 2019

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

@makeworld-the-better-one

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

@Zixim
Copy link

@Zixim Zixim commented Oct 31, 2019

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.
@eitch
Copy link

@eitch eitch commented Nov 27, 2019

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

@Zixim
Copy link

@Zixim Zixim commented Nov 27, 2019

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

@eitch
Copy link

@eitch eitch commented Nov 27, 2019

@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?

@Zixim
Copy link

@Zixim Zixim commented Nov 27, 2019

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.

@eitch
Copy link

@eitch eitch commented Nov 27, 2019

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet