Creating a whitelist for libreCMC routers: setting up DNS filtering

These directions have been tested on Linux Mint 21, but should work on most major GNU/Linux distributions. If you run into any trouble contact support.

If you are looking to block all but a few websites on your libreCMC router there is a way to do this relatively easily by creating a dnsmasq.conf file containing a list of all the sites you want to whitelist and uploading this file to the router. Creating this list is not straightforward as websites typically grab content from many other domains besides the one you're visiting. Thus to make this work you'll need to run a script first and then visit the sites you want to whitelist. The script will generate a tar.gz file that you can then upload to any libreCMC router. Once uploaded users will only be able to access sites in the whitelist.

1. To start open a terminal and copy and paste the below line (then hit enter, you will be prompted to enter your computer's login password, enter it and hit enter again):

rm -rf ~/librecmc-router-dnsmasq; mkdir -p ~/librecmc-router-dnsmasq/etc; sudo timeout -k 1240 1200 tcpdump -t -l -n -N 2> /dev/null | sed -n 's/.* A?* \([.a-z]\+\)\..*/server=\/\1\/#/p ' > ~/librecmc-router-dnsmasq/etc/dnsmasq.conf; sed -i '1iaddress=\/#\/127.0.0.1' ~/librecmc-router-dnsmasq/etc/dnsmasq.conf;cd ~/librecmc-router-dnsmasq/; tar -cf etc.tar.gz etc

This script will run for 20 minutes and log what websites you visit. You can change this by changing 1200 to however many seconds you want to script to run. 1200 equals 20 minutes. 600 would equal 10 minutes. After that you'll have a folder in your home directory called librecmc-router-dnsmasq and a tar.gz file inside it. This file is called etc.tar.gz and contains your whitelist configuration. We will upload it to the router.

If you open the etc folder you will see a file called dnsmasq.conf and this contains an address=/#/127.0.0.1 line alongside a list of servers that you have accessed while visiting the various websites over the past 20 minutes.

address=/#/127.0.0.1
server=/startpage.com/#

2. Open your web browser and go to https://192.168.10.1 and login (the default password if you have not changed it is the word 'none', but without the quotes)

Note: You may get a warning message when visiting https://192.168.10.1. You'll have to add an exception or click an advanced button to continue.

3. Once you've logged into the router go to System > Backup / Flash Firmware

4. Click the browse button under where it says Restore backup in the Restore area.

5. In your home folder you will find a directory called librecmc-router-dnsmasq and a file called etc.tar.gz. Click the the file and then the select button.

6. Then click the Upload archive... button.

When the router reboots the only websites you'll be able to access are those in which you previously visited. If you later discover you want to add to this list you can run through these directions again. You will need to start from scratch so make sure you revisit any web sites you've already got whitelisted.