Pages

Friday 27 March 2020

Open WRT as local DNS server to speed up internet

1. Set own DNS servers. Do this by adding config options in WAN section in /etc/config/network. Here I use Open DNS

uci set network.wan.dns="208.67.222.222 208.67.220.220"
uci commit
ifup wan

This only adds new servers. If we want to use only them do following:

uci set network.wan.dns="208.67.222.222 208.67.220.220"
uci set network.wan.peerdns=0
uci commit network
ifup wan

Here peerdns=0 means to ignore ISP delivered DNS

2. Force using router as DNS server.

It may happen that the client does not use DHCP but has manually set the IP address or set up another DNS server. DNS queries usually (see note below) are sent to port number 53, so if all the client traffic goes through our router then we can force our router to be used regardless of what the client has set. To do this, route all requests to the destination port 53 / tcp and 53 / udp to your router (assuming: the router has the address 192.168.1.1 and its LAN subnet is 192.168.1.0/24, which is the default OpenWrt configuration).


iptables -t nat -I PREROUTING -s 192.168.1.0/24 -p udp --dport 53 -j DNAT --to 192.168.1.1
iptables -t nat -I PREROUTING -s 192.168.1.0/24 -p tcp --dport 53 -j DNAT --to 192.168.1.1

(this can be added to the /etc/firewall.user file). Please note that your internet provider may also force the use of specific DNS servers, although it usually doesn't. While port 53 is the "standard" DNS service port, it happens that name servers can also listen on other ports. An example is the dnscrypt service which communicates on port 443. In networks using Tor, DNS is usually redirected to the built-in client anonymizing network.

Monday 23 March 2020

Strapi MongoError: not master and slaveOk=false

I tried using Strapi with cloud.mongodb.com and I got an error:

yarn run v1.19.1
$ strapi develop
[2020-03-23T19:00:55.263Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.507Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.509Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.791Z] debug ⛔️ Server wasn't able to start properly.
[2020-03-23T19:00:55.795Z] error MongoError: not master and slaveOk=false

All I was able to find out is that it has something to do with cluster configuration. I didn't see option to set slaveOk parameter anywhere in Strapi documentation. I'm sure there are better solutions to this but still I didn't want to spend too much time on this.

My fix was to add in database.json all 3 hosts within host line:

"host": "xxx-shard-00-00-rxyat.mongodb.net,xxx-shard-00-01-rxyat.mongodb.net,xxx-shard-00-02-rxyat.mongodb.net",

Friday 13 March 2020

Clear Linux available in Clover bootloader

I was struggling to get my Mac OS laptop boot also Clear Linux using Clover EFI loader. Making it tripple boot with Mac OS, Windows 10 and Clear Linux it would require following a sequence.

- First thing is to install Mac OS and make it boot via Clover.
- Second is to install (or restore Windows 10). Here make sure that Clover boots correctly both Mac OS and Windows.
- Third is to install Clear Linux. So create required primary partitions CLR_BOOT, CLR_SWAP and CLR_ROOT and proceed with the installation. When installation is completed make a copy of output from command blkid and reboot to Mac OS.

Now, in Clover Configurator mount EFI partition and load config which you use to boot Mac OS. Next go to GUI section, add new Custom Entry and enter only UUID of the CLR_BOOT partition and name which you want to see in Clover boot menu. When that's done, reboot and check if it worked.

Following pictures are for reference hoping they clearly ilustrate what to put and where.