Problem to set up dnsproxy

Hi,

I try to use dnsproxy with cloudlfare but I have problem with port in use and I don't find the problem.

Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [info] Starting dnsproxy v0.48.2
Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [info] fallback at index 0 is https://dns.cloudflare.com:443/dns-query
Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [info] Starting the DNS proxy server
Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [info] dnsproxy: cache: enabled, size 6553500 b
Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [info] Creating the UDP server socket
Mon Mar 27 12:29:19 2023 daemon.err dnsproxy[10699]: 2023/03/27 16:29:19 [fatal] cannot start the DNS proxy due to listening to udp socket: listen udp 127.0.0.1:5353: bind: address already in use
Mon Mar 27 12:29:19 2023 daemon.info procd: Instance dnsproxy::dnsproxy s in a crash loop 6 crashes, 0 seconds since last crash
Mon Mar 27 12:29:21 2023 daemon.err wifi-presence[10704]: Error: mqtt.addr cannot be blank
Mon Mar 27 12:29:22 2023 daemon.notice hostapd: wl1-ap0: AP-STA-DISCONNECTED d4:f5:47:34:08:8b

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 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 confdir '/etc/dnsmasq.d'
        option doh_backup_noresolv '-1'
        option noresolv '1'
        list server '/pool.ntp.org/1.1.1.1'
        list server '/time.cloudflare.com/1.1.1.1'
        list server '127.0.0.1#5353'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'

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 dhcp 'guest'
        option interface 'guest'
        option start '100'
        option limit '150'
        option leasetime '12h'

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

# For documents, please see https://github.com/AdguardTeam/dnsproxy#usage

config dnsproxy 'global'
        option enabled '1'
        option listen_addr '127.0.0.1'
        option listen_port '5353'
        option log_file ''
        option all_servers '0'
        option fastest_addr '0'
        option insecure '0'
        option ipv6_disabled '1'
        option max_go_routines ''
        option rate_limit ''
        option refuse_any '0'
        option udp_buf_size ''
        option verbose '0'

config dnsproxy 'bogus_nxdomain'
        list ip_addr ''

config dnsproxy 'cache'
        option enabled '1'
        option cache_optimistic '1'
        option size '6553500'
        option min_ttl ''
        option max_ttl ''

config dnsproxy 'dns64'
        option enabled '0'
        option dns64_prefix '64:ff9b::'

config dnsproxy 'edns'
        option enabled '0'
        option edns_addr ''

config dnsproxy 'servers'
        list bootstrap '1.1.1.1:53'
        list fallback 'https://dns.cloudflare.com/dns-query'
        list upstream 'h3://security.Cloudflare-dns.com/dns-query'

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 'fd83:4e9f:e4ec::/48'

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

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 '1.1.1.1'
        option metric '5'

config device
        option type 'bridge'
        option name 'br-guest'

config interface 'guest'
        option proto 'static'
        option device 'br-guest'
        option ipaddr '192.168.3.1'
        option netmask '255.255.255.0'

There is another service already listening on port 5353; execute this command to find out which process: "netstat -lunp | fgrep 5353".

2 Likes
netstat -lunp | fgrep 5353
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           2676/avahi-daemon: 
udp        0      0 :::5353                 :::*                                2676/avahi-daemon: 

Seems ok... Right?

Not really.
As you can see, port 5353 is already taken by the avahi-daemon.

Stop and disable the service or make dnsproxy listen on a different port (5354 for example).
Don't forget to edit /etc/config/dhcp as well.

3 Likes

ok great, if I choose 5354, in dnsproxy config Do I need to put 54 instead of 53 for 1.1.1.1:53?

config dnsproxy 'servers'
        list bootstrap '1.1.1.1:53'
        list fallback 'https://dns.cloudflare.com/dns-query'
        list upstream 'h3://security.Cloudflare-dns.com/dns-query'


and the new eeor I have is :slight_smile:

failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size for details.

I tried that but same error

root@OpenWrt:~# sysctl -w net.core.rmem_max=524288
net.core.rmem_max = 524288

No, leave it as it is.

cat << "EOF" > /etc/sysctl.d/12-rmem.conf
net.core.rmem_default = 2500000
net.core.rmem_max = 2500000
EOF

sysctl -p /etc/sysctl.d/12-rmem.conf
4 Likes

hi,

everytime I sysupgrade my build I need to adding again the lines you gave me?

https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#custom_files

1 Like

/files/etc/sysctl.conf

I guess it is <buildroot>/files/etc/sysctl.d/

just wondered why during sysupgrade, with keep setting option, these setting was erased

You have two options to create a file containing the following:

net.core.rmem_default = 2500000
net.core.rmem_max = 2500000
<buildroot>/files/etc/sysctl.conf

or

<buildroot>/files/etc/sysctl.d/some_name.conf

I did it from that

cat << "EOF" > /etc/sysctl.d/12-rmem.conf
net.core.rmem_default = 2500000
net.core.rmem_max = 2500000
EOF

sysctl -p /etc/sysctl.d/12-rmem.conf

This creates a file (with some settings) named 12-rmem.conf in /etc/sysctl.d .

This loads the settings from that file (without rebooting the router).

So, when you build a new image, just create a file <buildroot>/files/sysctl.d/12-rmem.conf containing those settings and you should be good.

1 Like

Use the config that survives sysupgrade by default:

Or customize the sysupgrade config to preserve extra files:

2 Likes
root@OpenWrt:/etc# cat sysctl.conf
# Defaults are configured in /etc/sysctl.d/* and can be customized in this file

so I need to use sysctl.d

You can add your custom settings to this file (/etc/sysctl.conf), insert them into some of the existing files in /etc/sysctl.d/, or create a new file in that same directory as I suggested initially.

EDIT:

Two possible solutions to preserve the settings during sysupgrade ( from the links provided by @vgaetera ) without adding custom files to your build.

cat << "EOF" >> /etc/sysctl.conf
net.core.rmem_default = 2500000
net.core.rmem_max = 2500000
EOF
echo "/etc/sysctl.d/12-rmem.conf" >> /etc/sysupgrade.conf
2 Likes

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