OpenWrt Forum Archive

Topic: Relay DNS server on DHCP

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

Hello, I have a Fonera with Openwrt, I want to relay the DNS servers to the computers with DHCP, I want to ask to DNS server directly from my computer.

This is my Openwrt network configuration:

# cat /etc/config/network 

config 'interface' 'loopback'
    option 'ifname' 'lo'
    option 'proto' 'static'
    option 'ipaddr' '127.0.0.1'
    option 'netmask' '255.0.0.0'

config 'interface' 'lan'
    option 'type' 'bridge'
    option 'proto' 'static'
    option 'netmask' '255.255.255.0'
    option 'ifname' 'eth0.0'
    option 'ipaddr' '192.168.2.1'
    option 'gateway' '192.168.1.1'
    option 'dns' '87.216.1.65 87.216.1.66'

config 'interface' 'wan'
    option 'ifname' 'eth0.1'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.2'
    option 'netmask' '255.255.255.0'
    option 'gateway' '192.168.1.1'
    option 'dns' '87.216.1.65 87.216.1.66'

And this is what I get on my Gnome laptop from DHCP:

http://i46.tinypic.com/2v82tde.png

How can I solve it? Is it better to manage the DNS asks from Openwrt?

Thanks for all and best regards.

Firstly your network configuration has nothing to do with DNS or DHCP *serving*.

To do dhcp options, you need to make your changes in the /etc/config/dhcp file.  See the output from `dnsmasq --help dhcp` to get the translation from option name to option number.

6 is the dns server option.  Here is the format of the entry for the config file:

list 'dhcp_option' '6,192.168.1.200'

So to fix your's:

config 'dhcp' 'lan'
        option 'interface' 'lan'
        option 'start' '100'
        option 'limit' '150'
        option 'leasetime' '12h'
        list 'dhcp_option' '6,87.216.1.65 87.216.1.66'

Apart from the list option, all the rest are the basic defaults, so simply add that one line to your current lan config section in /etc/config/dhcp

Thanks for your reply, I just probe to add this line but now I can get anything from DHCP, I must configure an static IP on the laptop to enter to the router.

There isn't an other "cleaner" way to do that? It will be great to take the DNS servers from my /etc/config/network configuration automatically.

Thanks for all, I will continue searching.

OK, my bad... there's a comma missing:

list 'dhcp_option' '6,87.216.1.65,87.216.1.66'

As for an easier way there is a web interface called LuCI that will allow you to enter DHCP options, however you still need to use other resources to find the right option and formatting.

Ohhh!!! Thanks! Now it works.

I will search for more, I need to take the DNS server from my ISP router that is connected on WAN interface, I will look for this.

Thanks again and best regards!

Why wouldn't you want the Fonera to service DNS requests?  That really doesn't make much sense.

The discussion might have continued from here.