Name server resolution

Hi all, I'm new on openwrt and I've just installed it. I have a very little problem in name resolution. openwrt can't solve LAN local names. My configuration seems to use this resolv.conf:

root@OpenWrt:~# cat /tmp/resolv.conf.d/resolv.conf.auto
# Interface lan
nameserver 192.168.64.2
search csaricerche.com

So if run nslookup I expect to be correctly resolved but it didn't

root@OpenWrt:~# nslookup mypc
Server:		127.0.0.1
Address:	127.0.0.1:53

** server can't find mypc.lan: NXDOMAIN

** server can't find mypc.lan: NXDOMAIN

ok, doesn't seems to use my default search domain... but even if I run

root@OpenWrt:~# nslookup mypc.csaricerche.com
Server:		127.0.0.1
Address:	127.0.0.1:53


Non-authoritative answer:

but if I ask to the dns server

root@OpenWrt:~# nslookup mypc.csaricerche.com 192.168.64.2
Server:		192.168.64.2
Address:	192.168.64.2:53

Name:	mypc.csaricerche.com
Address: 192.168.64.90

Non-authoritative answer:

This is my /etc/config/network configuration file:

root@OpenWrt:~# cat /etc/config/network

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

config globals 'globals'
	option ula_prefix 'fd24:e3be:8c99::/48'

config interface 'wan'
	option device 'eth1'
	option proto 'dhcp'

config interface 'wan6'
	option device 'eth1'
	option proto 'dhcpv6'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth0'

config device
	option name 'eth0'
	option macaddr '02:24:b2:59:0a:e2'

config interface 'lan'
	option proto 'dhcp'
	option device 'br-lan'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'
	option blinkrate '2'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '0 1 2 3 5'

config switch_port
	option device 'switch0'
	option port '1'
	option led '6'

config switch_port
	option device 'switch0'
	option port '2'
	option led '9'

config switch_port
	option device 'switch0'
	option port '5'
	option led '2'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth0'

My best regards

Piviul

Please look at /etc/config/dhcp.

You should have:

  • option local '/csaricerche.com/'
  • option domain 'csaricerche.com'
  • option expandhosts '1'

See: https://openwrt.org/docs/guide-user/base-system/dhcp

1 Like

Hi Stephan many thanks, I have applied your configuration to the dhcp file without success. Now the dnsmasq section of /etc/config/dhcp is:

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/csaricerche.com/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option cachesize '1000'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'
	option ednspacket_max '1232'
	option filter_aaaa '0'
	option filter_a '0'

but

root@OpenWrt:~# nslookup mypc
Server:		127.0.0.1
Address:	127.0.0.1:53

** server can't find mypc.lan: NXDOMAIN

** server can't find mypc.lan: NXDOMAIN

The parameters you suggest me to modify are valid even if the openwrt dhcp server is disabled?

Piviul

Yea, you set the domain to "lan" instead of "csaricerche.com".

That's why

  • your DHCP server assumes "if someone asks for 'mypc' without any domain, he clearly must mean 'mpc.lan'",
  • but since your router is local for "csaricerche.com", your DHCP server comes to the conclusion that he's not responsible for that request.

Use the same domain for both, the "domain" and the "local" property with the only difference being that "local" needs to be wrapped within slash characters.

1 Like

Hi golialive, you are right, now half problem is solved, the dnsmaq add the right local domain csaricerche.com:

root@OpenWrt:~# nslookup mypc.csaricerche.com
Server:		127.0.0.1
Address:	127.0.0.1:53

** server can't find mypc.csaricerche.com: NXDOMAIN

** server can't find mypc.csaricerche.com: NXDOMAIN

root@OpenWrt:~# nslookup mypc.csaricerche.com 192.168.64.2
Server:		192.168.64.2
Address:	192.168.64.2:53

Name:	mypc.csaricerche.com
Address: 192.168.64.90

Non-authoritative answer:

I say half problem because as you can see, seems that the dns doesn't query to 192.168.64.2 (the dns namserver) to solve mypc name.

Piviul

change the upstream DNS config ?
does openwrt need to be able to resolve the name too, or only the clients ?

I really don't get what you're trying to do here.

You need do decide:

Is OpenWRT responsible for answering requests for csaricerche.com?

If yes: Then why would it ask "upstream"? That's what "authoritative" means: Your OpenWRT has all the knowledge about csaricerche.com and doesn't need to ask anyone about csaricerche.com.

If no: Then don't tell it to hand out host names for this zone. If OpenWRT isn't the source where every information about csaricerche.com comes from then you shouldn't expect your router to have/provide "additional" information for csaricerche.com that doesn't come from "upstream".

Maybe just use "lan" and "/lan/" for both, "domain" and "local", have your computer named "mypc.lan" and be done.

Or use "lan.csaricerche.com" for "domain" and "local" and have your computer named "mypc.lan.csaricerche.com".

You're using (on purpose, I guess) a public domain for your local network. And you expect your router to be both, authoritative for that zone (being the one source of truth) and ask "upstream".

2 Likes

The best should be that they don't cache nothing, no dns service for the clients, we already have a dns server. The openwrt clients are bridged, they get the dns info by the dhcp of the lan, openwrt dhcp is disabled. in other word I don't need So I don't need dnsmasq I need only that openwrt use our DNS as a namserver.

is it possible?

Best regards

Piviul

Sure, but why not simply point the clients towards the upstream DNS ?

Yes, this is already done, i need only that openwrt, locally, use the upstream DNS too. In your opinion, removing dnsmasq should be a solution?

Piviul

no, it isn't.

I don't need in my LAN a further DNS managed by openwrt, the clients use the upstream DNS, I need only that openwrt ask to the upstream DNS to solve DNS querys.

Many thanks

Piviul

Try this:

In DHCP and DNS > Resolv &Host Files: Enable Ignore resolv file

In DHCP and DNS > Forwards > DNS Forwards: add 192.168.64.2

config dnsmasq
	list server '192.168.64.2'
	option noresolv '1'

1 Like

Does the name server at 192.168.64.2 have entries for the hosts in question?

doesn't work:

root@OpenWrt:~# nslookup mypc
Server: 127.0.0.1
Address: 127.0.0.1:53

** server can't find mypc.csaricerche.com: NXDOMAIN

** server can't find mypc.csaricerche.com: NXDOMAIN

Please explain: How would 192.168.64.2 know what A-record is assigned to "mypc"?

You're telling your OpenWRT to not hold any local data. So if you ask OpenWRT to tell you anything about "mypc", all it can do is pass that query along to 192.168.64.2.

Thanks egc, I wrong restarting the router solved the problem!

Thank you very much!

Piviul

1 Like

Yes Golialive, the local resolver have only to send the ip to the DNS upstream, nothing more. Now with the advice of egc I obtained this behavior.

Have a great day

Piviul

Great to hear it is working.

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.
Thanks! :slight_smile:

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