Can not resolve DNS name bad address error

Hello! Installed OpenWrt 23.05.5 on Xiaomi Mi Router 4A Gigabit Edition (moved from native firmware to install VPN on router). Made no changes to config, only installed password on radio0 and radio1 and enabled them. Internet is ok on clients via cable and via wi-fi. But trying to do opkg update throws error "Failed to send request: Operation not permitted". I searched web for solution, came to the DNS problem. Configured custom dns to all standard interfaces, applied changes, reboot but no use. Still ping 1.1.1.1 ok, ping google.com - bad address.

Pings from clients working ok (so DNS on clients is working)

Ping and nslookup from router:

root@OpenWrt:~# ping google.com
ping: bad address 'google.com'
root@OpenWrt:~# nslookup google.com
Server:         127.0.0.1
Address:        127.0.0.1:53

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

*** Can't find google.com: No answer

root@OpenWrt:~# cat /etc/resolv.conf
search lan
nameserver 127.0.0.1
nameserver ::1
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 'fd61:8fbb:5541::/48'
        option packet_steering '1'

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

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'
        list dns '1.1.1.1'
        list dns '1.0.0.1'
        list dns '8.8.8.8'
        list dns '8.8.4.4'
        list dns '77.88.8.1'
        list dns '77.88.8.8'

config interface 'wan'
        option device 'wan'
        option proto 'dhcp'
        option peerdns '0'
        list dns '77.88.8.1'
        list dns '8.8.8.8'
        list dns '8.8.4.4'
        list dns '1.1.1.1'

config interface 'wan6'
        option device 'wan'
        option proto 'dhcpv6'
        option reqaddress 'try'
        option reqprefix 'auto'
        option peerdns '0'
        list dns '8.8.8.8'
        list dns '1.1.1.1'
        list dns '8.8.4.4'
        list dns '1.0.0.1'
        list dns '77.88.8.1'
        list dns '77.88.8.8'

Internet is provided via Dynamic Ip (DHCP).
Any help is aprecciated. Thank you!

Don't use IPv4 addresses in the wan6 (IPv6) section:

Aside from that, lets see what happens when you run the following from the router:

nslookup openwrt.org 8.8.8.8
nslookup openwrt.org

And let's also see:

cat /etc/config/firewall
cat /etc/config/dhcp

Corrected DNS entries for IPv6, thanks!

There is output of listed commands:

root@OpenWrt:~# nslookup openwrt.org 8.8.8.8
gServer:                8.8.8.8
Address:        8.8.8.8:53

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

*** Can't find openwrt.org: No answer

root@OpenWrt:~# nslookup openwrt.org
Server:         127.0.0.1
Address:        127.0.0.1:53

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

*** Can't find openwrt.org: No answer

root@OpenWrt:~# cat /etc/config/firewall
config defaults
        option syn_flood        1
        option input            REJECT
        option output           ACCEPT
        option forward          REJECT
# Uncomment this line to disable ipv6 rules
#       option disable_ipv6     1

config zone
        option name             lan
        list   network          'lan'
        option input            ACCEPT
        option output           ACCEPT
        option forward          ACCEPT

config zone
        option name             wan
        list   network          'wan'
        list   network          'wan6'
        option input            REJECT
        option output           ACCEPT
        option forward          REJECT
        option masq             1
        option mtu_fix          1

config forwarding
        option src              lan
        option dest             wan

# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
        option name             Allow-DHCP-Renew
        option src              wan
        option proto            udp
        option dest_port        68
        option target           ACCEPT
        option family           ipv4

# Allow IPv4 ping
config rule
        option name             Allow-Ping
        option src              wan
        option proto            icmp
        option icmp_type        echo-request
        option family           ipv4
        option target           ACCEPT

config rule
        option name             Allow-IGMP
        option src              wan
        option proto            igmp
        option family           ipv4
        option target           ACCEPT

# Allow DHCPv6 replies
# see https://github.com/openwrt/openwrt/issues/5066
config rule
        option name             Allow-DHCPv6
        option src              wan
        option proto            udp
        option dest_port        546
        option family           ipv6
        option target           ACCEPT

config rule
        option name             Allow-MLD
        option src              wan
        option proto            icmp
        option src_ip           fe80::/10
        list icmp_type          '130/0'
        list icmp_type          '131/0'
        list icmp_type          '132/0'
        list icmp_type          '143/0'
        option family           ipv6
        option target           ACCEPT

# Allow essential incoming IPv6 ICMP traffic
config rule
        option name             Allow-ICMPv6-Input
        option src              wan
        option proto    icmp
        list icmp_type          echo-request
        list icmp_type          echo-reply
        list icmp_type          destination-unreachable
        list icmp_type          packet-too-big
        list icmp_type          time-exceeded
        list icmp_type          bad-header
        list icmp_type          unknown-header-type
        list icmp_type          router-solicitation
        list icmp_type          neighbour-solicitation
        list icmp_type          router-advertisement
        list icmp_type          neighbour-advertisement
        option limit            1000/sec
        option family           ipv6
        option target           ACCEPT

# Allow essential forwarded IPv6 ICMP traffic
config rule
        option name             Allow-ICMPv6-Forward
        option src              wan
        option dest             *
        option proto            icmp
        list icmp_type          echo-request
        list icmp_type          echo-reply
        list icmp_type          destination-unreachable
        list icmp_type          packet-too-big
        list icmp_type          time-exceeded
        list icmp_type          bad-header
        list icmp_type          unknown-header-type
        option limit            1000/sec
        option family           ipv6
        option target           ACCEPT

config rule
        option name             Allow-IPSec-ESP
        option src              wan
        option dest             lan
        option proto            esp
        option target           ACCEPT

config rule
        option name             Allow-ISAKMP
        option src              wan
        option dest             lan
        option dest_port        500
        option proto            udp
        option target           ACCEPT


### EXAMPLE CONFIG SECTIONS
# do not allow a specific ip to access wan
#config rule
#       option src              lan
#       option src_ip   192.168.45.2
#       option dest             wan
#       option proto    tcp
#       option target   REJECT

# block a specific mac on wan
#config rule
#       option dest             wan
#       option src_mac  00:11:22:33:44:66
#       option target   REJECT

# block incoming ICMP traffic on a zone
#config rule
#       option src              lan
#       option proto    ICMP
#       option target   DROP

# port redirect port coming in on wan to lan
#config redirect
#       option src                      wan
#       option src_dport        80
#       option dest                     lan
#       option dest_ip          192.168.16.235
#       option dest_port        80
#       option proto            tcp

# port redirect of remapped ssh port (22001) on wan
#config redirect
#       option src              wan
#       option src_dport        22001
#       option dest             lan
#       option dest_port        22
#       option proto            tcp

### FULL CONFIG SECTIONS
#config rule
#       option src              lan
#       option src_ip   192.168.45.2
#       option src_mac  00:11:22:33:44:55
#       option src_port 80
#       option dest             wan
#       option dest_ip  194.25.2.129
#       option dest_port        120
#       option proto    tcp
#       option target   REJECT

#config redirect
#       option src              lan
#       option src_ip   192.168.45.2
#       option src_mac  00:11:22:33:44:55
#       option src_port         1024
#       option src_dport        80
#       option dest_ip  194.25.2.129
#       option dest_port        120
#       option proto    tcp
root@OpenWrt:~# cat /etc/config/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'
        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'

root@OpenWrt:~#

Try removing all the DNS values from the lan interface (they don't really apply here anyway). Then restart and run the nslookup tests again.

Changed etc/config/network, then rebooted router:

root@OpenWrt:~# nslookup openwrt.org 8.8.8.8
Server:         8.8.8.8
Address:        8.8.8.8:53

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

*** Can't find openwrt.org: No answer

root@OpenWrt:~# nslookup openwrt.org
Server:         127.0.0.1
Address:        127.0.0.1:53

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

*** Can't find openwrt.org: No answer

root@OpenWrt:~# ping google.com
ping: bad address 'google.com'
root@OpenWrt:~# cat /etc/resolv.conf
search lan
nameserver 127.0.0.1
nameserver ::1
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 'fd56:af2e:6ca6::/48'
        option packet_steering '1'

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

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 'wan'
        option proto 'dhcp'
        option peerdns '0'
        list dns '8.8.8.8'
        list dns '8.8.4.4'

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

can you post the output of
opkg list

probably better to get the output of opkg list-installed

root@OpenWrt:~#  opkg list-installed
base-files - 1562-r24106-10cc5fcd00
busybox - 1.36.1-1
ca-bundle - 20230311-1
cgi-io - 2022-08-10-901b0f04-21
dnsmasq - 2.90-2
dropbear - 2022.82-6
firewall4 - 2023-09-01-598d9fbb-1
fstools - 2023-02-28-bfe882d5-1
fwtool - 2019-11-12-8f7fe925-1
getrandom - 2022-08-13-4c7b720b-2
hostapd-common - 2023-09-08-e5ccbfc6-8
iw - 5.19-1
iwinfo - 2023-07-01-ca79f641-1
jansson4 - 2.14-3
jshn - 2023-05-23-75a3b870-1
jsonfilter - 2024-01-23-594cfa86-1
kernel - 5.15.167-1-144de9e5c1a8813b724b14faa054d9f0
kmod-cfg80211 - 5.15.167+6.1.110-1-1
kmod-crypto-acompress - 5.15.167-1
kmod-crypto-aead - 5.15.167-1
kmod-crypto-ccm - 5.15.167-1
kmod-crypto-cmac - 5.15.167-1
kmod-crypto-crc32c - 5.15.167-1
kmod-crypto-ctr - 5.15.167-1
kmod-crypto-gcm - 5.15.167-1
kmod-crypto-gf128 - 5.15.167-1
kmod-crypto-ghash - 5.15.167-1
kmod-crypto-hash - 5.15.167-1
kmod-crypto-hmac - 5.15.167-1
kmod-crypto-manager - 5.15.167-1
kmod-crypto-null - 5.15.167-1
kmod-crypto-rng - 5.15.167-1
kmod-crypto-seqiv - 5.15.167-1
kmod-crypto-sha512 - 5.15.167-1
kmod-gpio-button-hotplug - 5.15.167-3
kmod-leds-gpio - 5.15.167-1
kmod-lib-crc-ccitt - 5.15.167-1
kmod-lib-crc32c - 5.15.167-1
kmod-lib-lzo - 5.15.167-1
kmod-mac80211 - 5.15.167+6.1.110-1-1
kmod-mt76-core - 5.15.167+2024-04-03-1e336a85-1
kmod-mt7603 - 5.15.167+2024-04-03-1e336a85-1
kmod-mt76x02-common - 5.15.167+2024-04-03-1e336a85-1
kmod-mt76x2 - 5.15.167+2024-04-03-1e336a85-1
kmod-mt76x2-common - 5.15.167+2024-04-03-1e336a85-1
kmod-nf-conntrack - 5.15.167-1
kmod-nf-conntrack6 - 5.15.167-1
kmod-nf-flow - 5.15.167-1
kmod-nf-log - 5.15.167-1
kmod-nf-log6 - 5.15.167-1
kmod-nf-nat - 5.15.167-1
kmod-nf-reject - 5.15.167-1
kmod-nf-reject6 - 5.15.167-1
kmod-nfnetlink - 5.15.167-1
kmod-nft-core - 5.15.167-1
kmod-nft-fib - 5.15.167-1
kmod-nft-nat - 5.15.167-1
kmod-nft-offload - 5.15.167-1
kmod-ppp - 5.15.167-1
kmod-pppoe - 5.15.167-1
kmod-pppox - 5.15.167-1
kmod-slhc - 5.15.167-1
libblobmsg-json20230523 - 2023-05-23-75a3b870-1
libc - 1.2.4-4
libgcc1 - 12.3.0-4
libiwinfo-data - 2023-07-01-ca79f641-1
libiwinfo20230701 - 2023-07-01-ca79f641-1
libjson-c5 - 0.16-3
libjson-script20230523 - 2023-05-23-75a3b870-1
liblucihttp-ucode - 2023-03-15-9b5b683f-1
liblucihttp0 - 2023-03-15-9b5b683f-1
libmbedtls12 - 2.28.9-1
libmnl0 - 1.0.5-1
libnftnl11 - 1.2.6-1
libnl-tiny1 - 2023-07-27-bc92a280-1
libpthread - 1.2.4-4
libubox20230523 - 2023-05-23-75a3b870-1
libubus20230605 - 2023-06-05-f787c97b-1
libuci20130104 - 2023-08-10-5781664d-1
libuclient20201210 - 2023-04-13-007d9454-1
libucode20230711 - 2024-07-11-1a8a0bcf-3
libustream-mbedtls20201210 - 2023-02-25-498f6e26-1
logd - 2022-08-13-4c7b720b-2
luci - git-23.051.66410-a505bb1
luci-app-firewall - git-24.067.01746-69867db
luci-app-opkg - git-24.148.43905-2891ca4
luci-base - git-24.264.56413-c7a3562
luci-light - git-23.024.33244-34dee82
luci-mod-admin-full - git-19.253.48496-3f93650
luci-mod-network - git-24.264.56960-63ba3cb
luci-mod-status - git-24.212.61237-b6da3f2
luci-mod-system - git-24.067.01860-7a82b2f
luci-proto-ipv6 - git-24.086.45108-51aee90
luci-proto-ppp - git-24.135.44542-f1ec9c2
luci-ssl - git-23.035.26083-7550ad6
luci-theme-bootstrap - git-24.086.46634-1ffe078
mtd - 26
netifd - 2024-01-04-c18cc79d-2
nftables-json - 1.0.8-1
odhcp6c - 2023-05-12-bcd28363-20
odhcpd-ipv6only - 2023-10-24-d8118f6e-1
openwrt-keyring - 2022-03-25-62471e69-2
opkg - 2022-02-24-d038e5b6-2
ppp - 2.4.9.git-2021-01-04-4
ppp-mod-pppoe - 2.4.9.git-2021-01-04-4
procd - 2023-06-25-2db83655-2
procd-seccomp - 2023-06-25-2db83655-2
procd-ujail - 2023-06-25-2db83655-2
px5g-mbedtls - 10
rpcd - 2023-07-01-c07ab2f9-1
rpcd-mod-file - 2023-07-01-c07ab2f9-1
rpcd-mod-iwinfo - 2023-07-01-c07ab2f9-1
rpcd-mod-luci - 20240305-1
rpcd-mod-rrdns - 20170710
rpcd-mod-ucode - 2023-07-01-c07ab2f9-1
ubi-utils - 2.1.5-1
ubox - 2022-08-13-4c7b720b-2
ubus - 2023-06-05-f787c97b-1
ubusd - 2023-06-05-f787c97b-1
uci - 2023-08-10-5781664d-1
uclient-fetch - 2023-04-13-007d9454-1
ucode - 2024-07-11-1a8a0bcf-3
ucode-mod-fs - 2024-07-11-1a8a0bcf-3
ucode-mod-html - 1
ucode-mod-math - 2024-07-11-1a8a0bcf-3
ucode-mod-nl80211 - 2024-07-11-1a8a0bcf-3
ucode-mod-rtnl - 2024-07-11-1a8a0bcf-3
ucode-mod-ubus - 2024-07-11-1a8a0bcf-3
ucode-mod-uci - 2024-07-11-1a8a0bcf-3
ucode-mod-uloop - 2024-07-11-1a8a0bcf-3
uhttpd - 2023-06-25-34a8a74d-2
uhttpd-mod-ubus - 2023-06-25-34a8a74d-2
urandom-seed - 3
urngd - 2023-11-01-44365eb1-1
usign - 2020-05-23-f1f65026-1
wireless-regdb - 2024.07.04-1
wpad-basic-mbedtls - 2023-09-08-e5ccbfc6-8

without updating the output should be similar

the main problem is that the ipv6 reply from dns server is not being received by dnsmasq. did you disable some ipv6 configuration?

Nope, all i did with fresh installation is:
Configure 2.4 and 5 Wi-Fi modules (set password, enabling them);
Added custom DNS to wan interface.
All of this done with LuCI

If you don't have a proper dual-stack, try simply removing the wan6 interface. Restart and test again.

Now interfaces page looks like that; Rebooted device

But still

root@OpenWrt:~# nslookup openwrt.com 8.8.8.8
Server:         8.8.8.8
Address:        8.8.8.8:53

Non-authoritative answer:
Name:   openwrt.com
Address: 5.8.93.86

*** Can't find openwrt.com: No answer

:upside_down_face:

Yes, i don't have an ipv6 support by my provider at all. Maybe it was worth mentioning from the start

let's see the output of

ping duckduckgo.com

nslookup duckduckgo.com

root@OpenWrt:~# ping duckduckgo.com
ping: bad address 'duckduckgo.com'
root@OpenWrt:~# nslookup duckduckgo.com
Server:         127.0.0.1
Address:        127.0.0.1:53

Non-authoritative answer:
Name:   duckduckgo.com
Address: 40.114.177.156

*** Can't find duckduckgo.com: No answer

Hi @tenkovin

maybe your ISP is blocking port 53 forward
so
please let DHCP on WAN interface grab correct DNS address, hopefuly from ISP

I doubt that... we do see results from the DNS lookups (non-authoritative, but still valid).

try to edit the /etc/config/dhcp file and replace the line

option filter_aaaa '0'

to

option filter_aaaa '1'

then restart the router and see the output of

nslookup duckduckgo.com

*not forget to save the file properly

1 Like

It helped!! Thank you! I have no clue how you came to that particular string on file but still!

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

Non-authoritative answer:
Name:   duckduckgo.com
Address: 40.114.177.156

Non-authoritative answer:

root@OpenWrt:~# ping google.com
PING google.com (64.233.164.102): 56 data bytes
64 bytes from 64.233.164.102: seq=0 ttl=112 time=19.919 ms
64 bytes from 64.233.164.102: seq=1 ttl=112 time=19.883 ms
64 bytes from 64.233.164.102: seq=2 ttl=112 time=19.810 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 19.810/19.870/19.919 ms

Thank you everyone who answered. I really appreciated it