Help configuring DNS?

I have something wrong in my DNS configuration, and I'm not quite sure what.

The general internet works just fine, but when I try to set up an internally-resolving hostname (LuCI -> Network -> Hostnames), that hostname does not work.

This is my /etc/config/dhcp file:

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option localservice '1'
        list server '8.8.8.8'
        list server '8.8.4.4'
        list server '2001:4860:4860::8888'
        list server '2001:4860:4860::8844'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        option ra_management '1'
        option limit '51'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config domain
        option name 'wiki.mydomain.com'
        option ip '192.168.99.20'

I replaced my actual domain, businessname [dot] com, that I own, in that code block. That isn't the error.

ping wiki.mydomain.com returns my public IP, not 192.168.99.20

If I manually set my computer's DNS servers to the router, then it works.

If I don't add any manual DNS settings, ipconfig reports my DNS servers as:

DNS Servers . . . . . . . . . . . : 2001:4860:4860::8888
                                       2001:4860:4860::8844
                                       192.168.99.1

What am I missing here?

It works the old fashioned way by putting it in /etc/hosts. I'm not sure what the UCI way is.

Are you sure it's not using IPv6?

Added to the hosts file and it works now. Thanks.

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

You should remove the list server directives. They tell which DNS servers to hand to clients. That means clients will then directly send their queries to these servers. But clearly you want dnsmasq to do this to handle your custom domain. You should only have one line with list server 192.168.99.1. Additionally, you need to add the DNS servers from Google to your WAN-interface. Thus, they will end up in resolv.conf and will be what dnsmasq itself uses for lookups.[quote="treysis, post:5, topic:71614, full:true"]
You should remove the list server directives. They tell which DNS servers to hand to clients. That means clients will then directly send their queries to these servers. But clearly you want dnsmasq to do this to handle your custom domain. You should only have one line with list server 192.168.99.1. Additionally, you need to add the DNS servers from Google to your WAN-interface. Thus, they will end up in resolv.conf and will be what dnsmasq itself uses for lookups.

@treysis Ok, I fixed that.

I have Google's DNS servers listed in the WAN interface in LuCI, but resolv.conf is just

search lan
nameserver 127.0.0.1

Is this right?

2020-08-13 13_21_47-Window

Oopsie I am very sorry and I can't believe I made this mistake: your configuration was actually right! list server are the upstream DNS that dnsmasq uses, not what is passed to clients.

I was just surprised why your client picks up Google's DNS. Probably it's distributed via odhcpd. May you share your odhcpd.conf?

2 Likes

https://openwrt.org/docs/guide-user/firewall/fw3_configurations/intercept_dns

1 Like

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