The defaults for Unbound work very well and showcase convincingly how much we need to use this program on any supported Asus/RMerlin router. All you have to do is install it at bare defaults and answering 'no' (by pressing the Enter button in unbound_manager v2.06) to each question presented. Now, go browse your favorite sites. Make sure to open links within the main site to see unbound at work. Open amtm in a PuTTY session (or the terminal of your choice) and check for updates, or, simply see how fast your shares show up on your NAS or other shared network drives and compare how the network responded before.
With the link to the nitty-gritty details of how Unbound works under the hood, I thought I would see what changes I could make, if any, to make my network respond
faster.
https://nlnetlabs.nl/documentation/unbound/unbound.conf/
The link above is what I'm trying to comprehend and implement in my suggestions below for improved performance over the original defaults.
I also answer 'y' to the installer ('i') when asked for the CPU/Memory Performance tweaks (stuning), so the 'defaults/Orig' values below may reflect that too.
My current router is a 4 core, 1GB RAM, RT-AX88U connected to a 1Gbps up/down symmetrical ISP (nominal) connection running RMerlin 384.15 Beta 1 firmware.
The changes I have made have been commented with what the current default was and a suggested setting for the RT-AC86U which is a 2 core, 512GB RAM router that unbound also supports.
Code:
# no threads and no memory slabs for threads
num-threads: 4 # L&LDv1.03 (Orig 1) RT-AX88U For RT-AC86U use (2)
msg-cache-slabs: 4 # L&LDv1.03 (Orig 2) RT-AX88U For RT-AC86U use (2)
rrset-cache-slabs: 4 # L&LDv1.03 (Orig 2) RT-AX88U For RT-AC86U use (2)
infra-cache-slabs: 4 # L&LDv1.03 (Orig 2) RT-AX88U For RT-AC86U use (2)
key-cache-slabs: 4 # L&LDv1.03 (Orig 2) RT-AX88U For RT-AC86U use (2)
# tiny memory cache
key-cache-size: 16m # L&LDv1.03 (Orig 8m) RT-AX88U For RT-AC86U use (8m)
msg-cache-size: 16m # L&LDv1.03 (Orig 8m) RT-AX88U For RT-AC86U use (8m)
rrset-cache-size: 32m # L&LDv1.03 (Orig 16m) RT-AX88U For RT-AC86U use (16m)
cache-max-ttl: 21600
cache-min-ttl: 0 # L&LDv1.03 (Orig 5) RT-AX88U or RT-AC86U
prefetch: yes
prefetch-key: yes
serve-expired: yes
serve-expired-ttl: 3600
incoming-num-tcp: 1024 # L&LDv1.03 (Orig 600) RT-AX88U For RT-AC86U use (1024)
outgoing-num-tcp: 256 # L&LDv1.03 (Orig 100) RT-AX88U For RT-AC86U use (512)
ip-ratelimit: 0 # L&LDv1.03 (Orig 100) RT-AX88U For RT-AC86U use (0)
edns-buffer-size: 4096 # L&LDv1.03 RT-AX88U (Orig (1472) v1.01 as per @dave14305 minimal config)
Some key points to note about the changes above. Please refer to the link above and offer corrections on my assumptions.
Proceed only if you take full responsibility for any possible disruptions
to your network or your working router configuration.
I will try to explain each change I've made, but it is up to you to understand
how this may impact your router and the network.
Before making any changes to your unbound.conf file located in /opt/var/lib/unbound/ make a backup and store it in a safe location.
- num-threads:
- This should equal the number of Cores your router's CPU has. For the RT-AX88U: 4.
- The following should all be the same:
- msg-cache-slabs:
- This should be close to the number of Cores and must be a power of 2. For the RT-AX88U: 4.
- rrset-cache-slabs:
- This should be close to the number of Cores and must be a power of 2. For the RT-AX88U: 4.
- rrset-cache-slabs:
- This should be close to the number of Cores and must be a power of 2. For the RT-AX88U: 4.
- infra-cache-slabs:
- This should be close to the number of Cores and must be a power of 2. For the RT-AX88U: 4.
- key-cache-slabs:
- This should be close to the number of Cores and must be a power of 2. For the RT-AX88U: 4.
- key-cache-size:
- The largest value that didn't crash the RT-AX88U: 16m.
- msg-cache-size:
- The largest value that didn't crash the RT-AX88U: 16m.
- rrset-cache-size:
- This value should be twice the value of the msg-cache-size above. For the RT-AX88U: 32m.
- cache-min-ttl: '0' is the (DNS) servers' default value (anything else here over-rides that).
- incoming-num-tcp: '1024' is the maximum value allowed (except in a Linux build).
- outgoing-num-tcp: '256' is 1024 divided by the number of cores.
- ip-ratelimit: '0' disables global rate-limiting per IP address. Look at the link above to see if you want to change from the '5' default.
- edns-buffer-size: '4096' is the RFC recommended value.
With the above settings for my RT-AX88U, surfing and networking performance seems to be at a peak but I welcome any suggestions to make it even faster and more reliable too.
Finally, I'll repeat here what I've posted previously:
I recommend having both PuTTY and WinSCP open when trying this (or your terminal and editors of choice).
Use WinSCP to keep the unbound.conf file open (make sure you hit save after any changes, of course).
Use PuTTY to issue an 'rs' restart command to unbound_manager after saving your changes.
After restarting unbound_manager and it starts up normally, see if the unbound.log file is 'clean' (using WinSCP). Make sure to refresh the file a few times. If you are using Scribe and uiScribe, you can see this output in System Log and the 'unbound.log' log.
(If you have installed Scribe and uiScribe already from amtm, in unbound_manager, simply select 3, scribe (enter) to see the log in the GUI).
Browse some sites, making sure to click on links that stay within that main site, open up some files on your NAS, if available and report back, please.
If there is an issue, simply undo the changes you made and save the unbound.conf file again. You may need to reboot the router to be able to issue an 'rs' command again though.
Remember to reboot the router and test afterward too that unbound is still running (let your router settle for 5 minutes or so before testing after the reboot).
The default settings should work with all routers. But if you're using a router other than the RT-AC86U or the RT-AX88U that is also dual-core, change
just the following from their default values:
- num-threads: 2
- cache-min-ttl: 0
- incoming-num-tcp: 1024
- outgoing-num-tcp: 256
- ip-ratelimit: 0
- edns-buffer-size: 4096
And most of all, I would recommend running your networks with the unbound_manager defaults for at least a few hours of actual use. Then, see if the changes above improve on
that.
Thank you
@rgnldo and
@Martineau and the many others who created this for Asus/RMerlin users!
Happy, fast and 'snappy' network browsing to all!
I hope this small 'guide' allows us to find (and share) the best settings for Unbound for each of us.