DNS resolving fail at first try?

It happens that name resolving fails at first try for example:

~# ping google.com
ping: bad address 'google.com'
~# ping google.com
PING google.com (142.251.209.46): 56 data bytes
64 bytes from 142.251.209.46: seq=0 ttl=116 time=9.819 ms

no matter the site. Also wget, curl or opkg update commands fail at first try.
nslookup behaviour slightly different, first time:
nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1:53

** server can't find google.com: NXDOMAIN

Non-authoritative answer:
Name: google.com
Address: 142.251.209.46

second time:

~# nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1:53

Non-authoritative answer:
Name: google.com
Address: 142.251.209.46

Clean install of openwrt23, wan port connected as dhcp client to my home router lan.

Devices connected directly to home router never fail to resolve names.

Solved forcing wan interfaces of openwrt router to use custom dns (8.8.8.8)
instead of home router ip provided by dhcp.

There were no problems with older openwrt.

One of your configured DNS servers is active, but not able to resolve google.com so it returns NXDOMAIN. NXDOMAIN is a valid result, so the system does not fail over to another server.

2 Likes

Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board; \
uci export network; \
uci export dhcp; \
ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/* ; head -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
1 Like
:~# ubus call system board; \
> uci export network; \
> uci export dhcp; \
> ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/* ; head -n -0 /etc/resolv.*
/tmp/resolv.* /tmp/resolv.*/*
{
        "kernel": "5.15.134",
        "hostname": "xxxxxx",
        "system": "MediaTek MT7628AN ver:1 eco:2",
        "model": "GL-MT300N-V2",
        "board_name": "glinet,gl-mt300n-v2",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "23.05.0",
                "revision": "r23497-6637af95aa",
                "target": "ramips/mt76x8",
                "description": "OpenWrt 23.05.0 r23497-6637af95aa"
        }
}
package 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 'fdae:b832:7367::/48'

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

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

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

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '0 6t'

config interface 'wwan'
        option proto 'dhcp'

package dhcp

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 '/lan/'
        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'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'server'
        option ra 'server'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'

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'

lrwxrwxrwx    1 root     root            16 Oct  9 23:45 /etc/resolv.conf -> /tm                       p/resolv.conf
-rw-r--r--    1 root     root            47 Oct  9 23:51 /tmp/resolv.conf
-rw-r--r--    1 root     root            40 Oct  9 23:51 /tmp/resolv.conf.d/reso                       lv.conf.auto

/tmp/resolv.conf.d:
-rw-r--r--    1 root     root            40 Oct  9 23:51 resolv.conf.auto
==> /etc/resolv.conf <==
search lan
nameserver 127.0.0.1
nameserver ::1

==> /tmp/resolv.conf <==
search lan
nameserver 127.0.0.1
nameserver ::1

==> /tmp/resolv.conf.d <==
head: /tmp/resolv.conf.d: I/O error

==> /tmp/resolv.conf.d/resolv.conf.auto <==
# Interface wwan
nameserver 192.168.3.1

You can try to query the nameserver directly.
nslookup openwrt.org 192.168.3.1
It will have the same problem.
Better add some specific nameservers to be used instead of this one:

uci add_list network.wwan.dns='8.8.8.8'
uci add_list network.wwan.dns='1.1.1.1'
uci commit network
ifup wwan

Fixed typo with interface name.

2 Likes

That's what I did to solve the problem. But can't figure out why this happens. openwrt19 works fine. while with openwrt23:
first try after reboot or new name to be resolved differs from next times

~# nslookup openwrt.org 192.168.3.1
Server:         192.168.3.1
Address:        192.168.3.1:53

** server can't find openwrt.org: NXDOMAIN

Non-authoritative answer:
Name:   openwrt.org
Address: 139.59.209.225

~# nslookup openwrt.org 192.168.3.1
Server:         192.168.3.1
Address:        192.168.3.1:53

Non-authoritative answer:
Name:   openwrt.org
Address: 139.59.209.225

** server can't find openwrt.org: NXDOMAIN

That is a question for the nameserver on 3.1 and why it is answering with NXDOMAIN. What is this device?

2 Likes

yes, it my home router fault d-link DVA-5592_A1_WI_20191219 or internet provider dns, but no other device complains about this. all in all the address is resolved

I could suggest you to run a tcpdump, but I don't think we'll see anything interesting there.
I believe you have limited to no access at all on the dlink, hence not much you can troubleshoot. Solutions I can think:

  1. Change the DNS and enjoy your weekend.
  2. Collect packet captures from working and not working examples, be prepared to open tickets with your ISP.

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