OpenWrt Forum Archive

Topic: How to specify DNS nameserver offered to DHCP clients

The content of this topic has been archived on 26 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Ok, i'm fairly technical and pretty tech savvy and have read all the docs howtos but cant get rc5 to do the "right thing" for my setup. Essentially i need dnsmasq to offer a DNS nameserver to DHCP clients other than the IP address of the router itself.

So what i have in my internal network is a DNS bind9 nameserver set up to do 'views' so that depending on the internal host that's querying it. it offers different answers for hostname -> IP resolution. However irrespective of any setting i can think of, OpenWRT always serves itself up as the nameserver for DHCP clients.

An example: Say my network is like so

Host A: the OpenWRT router
Host B: the Bind 9 nameserver
Host C: a Linux DHCP laptop
Host D: a MacOSX DHCP laptop

Now i've set nvram_dns on A to point to B

If i bring up host C using DHCP, then its /etc/resolv.conf always gets set to host A
If i bring up host D the same thing happens, it sets host A as the nameserver

What config do i need to do on OpenWRT to specify that it should push host B as the nameserver ?

Help, my hair is nearly all gone... What am i doing wrong ? What have i missed ???

I think (?) what you want is to add this to /etc/dnsmasq.conf:

dhcp-option=6,<IP of name server(s)>

The document I have on this suggests looking at RFC 2132 for available options.

yawlhoo wrote:

I think (?) what you want is to add this to /etc/dnsmasq.conf:

dhcp-option=6,<IP of name server(s)>

*IF* you've enabled your dnsmasq to use /etc/dnsmasq.conf.  By default in RC5, dnsmasq is configured directly out of /etc/init.d/S50dnsmasq.

Guys thanks a lot. That worked perfectly.

And thanks also 'bluesguy' for pointing out that all previous changes to /etc/dnsmasq.conf are totally ignored. Which explains why a lot of my changes were ignored.

Clever idea to put a dnmasq.conf file in the distribution to give us a false sense that it's actually being used.

It'd be nice to have a web interface to the DHCP page to set these values. Maybe i'll make the change..

FAQ maintainer, please put this in.

Thanks again

dm66 -

I'm trying to make changes to dnsmasq.conf in RC6 and am having the same issue of the changes being ignored.  I'd like to use external DNS servers instead of the DNS servers supplied by my ISP. 

Can you post the changes that you made to dnsmasq.conf and S50dnsmasq? 

Thanks...

if i am running a dhcp client on the wan
a dhcp server on the static lan
nat between
i want to tell dhcp clients to use the dhcp server learned from the wan dhcp client

think hotel ether with wireless laptops and the hotel is doing dns hacking

clue bat please

Dnsmasq will send it's own address as the dns server for dhcp clients, the upstream dns servers that dnsmasq uses are determined by resolv.conf (/tmp/resolv.conf.auto in rc6).

In RC6,  the dns servers presented to the dhcp clients can be modified by adding the following line to /etc/dnsmasq.conf

dhcp-option=6,ipaddress1,ipaddress2

where ipaddress1 and ipaddress2 are the ip's of the dns servers that you want to present to the clients.

These addresses will be presented to the clients even though the resolve.conf file will show different nameservers.

The discussion might have continued from here.