Beginner: Setting another DNS server

Hi! I'm getting a Raspberry Pi soon and I'm going to install Pi-Hole on it. I am investigating ways to have it be my DNS server. From searching the forums, I know you can do in LUCI: Network>Interfaces>Wan>Advanced Settings>Uncheck 'Use DNS service advertised by peer' and insert Pi's static IP into 'Use custom DNS servers'. I think also, in advanced dnmasq settings, you can specify additional servers in a file (presumably that you touch whilst SSHing into the router and edit) and possibly edit the resolv file in order that these servers be queried first, not sure about this one, am I right here?

So what I'm wondering is which is the right way to go about this, and also, because I am am a beginner trying to learn the command line, I would like to know if these configurations can be done in the command line and how. I cannot see anything in /etc/config/network or /etc/config/dhcp which would seem to do what I am intending.

I appreciate technical explanations so that I can learn, thank you.


Hello, I am slowly reading through the documentation. Could you clarify using the UCI for me:


My understanding is this refers to 'network' config, and the first 'switch' type under that config. [0] is notation like an array in C and defines it as the first switch type. But why is there an @? Sometimes it is present and sometimes it is not.

1 Like

Yep, you are correct.
There are 2 methods to address sections:

  • By anonymous-name like an array, the syntax requires @ at the beginning.
  • By name for named sections, or by autogenerated CFGID for unnamed ones.

Both methods are valid and can be used at any time:

1 Like

Thankyou this makes it clear.

1 Like

I run pihole myself but I use piholes DHCP server,
If you want to use OpenWrt as your DHCP server you will need to use option 6 that way your clients will use piholes IP as your DNS server, Sorry I don't have any links to give you right now.

If you just use the DNS settings in General LAN setting pihole will log all your clients as coming from the routers IP which is not desirable.

Hello. What is 'option 6'?

Do you mean that if I set up a custom DNS server, pi-hole will log all the clients as my router's ip?

1 Like

I'm afraid this hasn't made it any clearer. Do you mean no. 6 on that list, 'Domain Server'? I don't know what this means.

We're talking about adding DHCP options (respectively overriding the defaults) to the DHCP leases handed out by dnsmasq on your router, as listed in the reference table in my link, option 6 is "Domain Server" <-- overriding the default DNS source in the DHCP lease.

1 Like

So, you're talking about making the Pi do DHCP? I think I might not bother with pi-hole and just make a minecraft server or something, I don't understand this stuff.

You might not understand this stuff now, but by taking the time to learn about this stuff and engage with it in a hands-on fashion, that can easily change. I suppose it's a matter of whether you want to or not.

Perhaps you may find it helpful if some of the information you've been given could be pulled together a bit. Here's my attempt at that:

To build upon what sml156 told you, you have two primary options to consider. Either the pi-hole can be your DHCP server or your router can continue to be your DHCP server.

If you go with the pi-hole DHCP server, it's only a matter of disabling the DHCP server in OpenWrt. Pretty straightforward if everything else is setup properly.

If you go with the OpenWrt DHCP server, you need a way to tell the devices to use the pi-hole for DNS things (this is already handled for you if you use the pi-hole DHCP server). This post on their forums, which is linked in their docs, is sufficiently illustrative. You can follow the instructions that have already been linked to you about setting DHCP options in OpenWrt to get the specifics, but the goal is the same.

The two options should function in very similar manners. The only notable difference that I can find is that you will only see device names in the pi-hole management interface if you are also using pi-hole's DHCP server. Else, you will just see IP addresses.

Based on your replies, it may be helpful to read up a bit on DHCP's basic functionality and how options come into play. is not bad, though you may find more approachable/beginner-friendly resources with a quick internet search.

slh's most recent reply was clarifying that the directions up to this point have been how to use your existing DHCP server, the one provided by OpenWrt, with pi-hole. Though it seems that you interpreted quite the opposite, having the pi-hole do DHCP is not what people have been providing instructions for.

And hey, if this isn't right for you right now, no worries! I bet you will still learn a thing or two setting up your Minecraft server. :slight_smile:

Hi I was in a rush this afternoon and hoped that you would search the forum or Google to learn more about "option 6" but now I got a bit more time.

The links provided in this post show how to enable option 6 using SSH, Since I chose to use Pihole as a DHCP server I do not have the same DHCP and DNS settings in the web GUI (Lucy) as you do now so as they say a picture is worth a thousand words so I searched Google for some pictures.

Here is what your looking for in Lucy ( 6, ) yours will be empty so you have to use " 6, piholes IP

Ah okay thanks guys. I understand now. Sorry I was getting a bit flustered. My aim is to learn but I was not following what people were saying to me. I will take some time to read up, I did spend what felt like the whole weekend reading documentation for OpenWRT and about networking but it is a lot to take in.

So the simplest thing to do is disable DHCP in OpenWRT and have pi-hole handle DHCP and DNS. I was confused because pi-hole states it needs a static ip, and you set this via DHCP config on router. I assume if you make pi-hole the DHCP server, it assigns itself a static ip.

edit: I think I am not going to bother with pi-hole. I want the pi to play with, I don't want my network to go down if I break it. I think I'm just going to set up a server on the pi.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.