Telfort Glasvezel met ASUS RT-AC68U router

Na twee jaar met de Experiabox v8 te hebben gewerkt in combinatie met een Telfort Glasvezel abonnement, is het tijd om deze te vervangen. Ter vervanging van de Experiabox v8 heb ik de ASUS RT-AC68U aangeschaft.

Het belangrijkste is dat internet en IPTV blijven werken. Ik maak geen gebruik van telefonie, waardoor VOIP niet in deze uitleg wordt meegenomen.

Nu ben ik niet de eerste die de waardeloze Experiabox v8 wil vervangen, dus er zijn genoeg fora te vinden waarop wordt uitgelegd hoe je de router moet inrichten om te zorgen dat het probleemloos werkt.

Deze instructie is gebaseerd op dit forumthread van Tweakers

VLAN’s

Telfort heeft – net als KPN – het netwerk opgedeeld in VLAN’s. Hierdoor kan het meerdere diensten over één verbinding aanbieden, zonder dat deze last hebben van elkaar.

Telfort gebruikt de volgende VLAN’s:

  • 4 – IPTV
  • 7 – VOIP (wordt niet gebruikt in deze handleiding)
  • 34 – Internet

De ASUS router gaat straks deze verschillende VLAN’s scheiden en zorgen dat het netwerkverkeer op de juiste plek terecht komt.

Routed vs Bridged

Het is mogelijk om op twee manieren de verbinding voor internet en IPTV in te stellen.

Bridged

In Bridged mode configureer je de router via de webinterface. Daarin wordt ingesteld welk VLAN voor het internet is en welke voor IPTV. De router zorgt ervoor dat het juiste VLAN aan een poort wordt gekoppeld.

In Bridged mode werken niet alle functies op de settopbox die Telfort meelevert. Zo werkt On Demand niet, en Apps op TV is ook niet te gebruiken.

Dit wordt niet gebruikt.

Routed

In Routed mode configureer je de router voornamelijk via de CLI d.m.v. een SSH-verbinding of Telnet.

In Routed mode krijgt de settopbox een IP-adres van de DHCP-server in het netwerk, en zorgt de router ervoor dat het verkeer van IPTV wordt gescheiden van het internetverkeer.

Hierdoor kan de settopbox verbinding maken met diensten die niet via het VLAN van IPTV wordt aangeboden. Zo werkt via Routed mode de eerder genoemde On Demand en Apps op TV zonder problemen.

Configuratie van ASUS RT-AC68U

Webinterface

Het eerste deel van de configuratie vind plaats in de webinterface van de router. Open daarvoor de webinterface van de router.

  • Navigeer naar LAN > IPTV
  • Selecteer bij ISP Profile: Manual Setting
  • Vul bij Internet het VID 34 in, en bij PRIO 1
  • Selecteer bij Use DHCP routes: RFC3442 & Microsoft
  • Selecteer bij Enable multicast routing (IGMP Proxy): Enable
  • Selecteer bij Enable efficient multicast forwarding (IGMP Snooping): Enable
  • Klik op Apply

MAC-adres wijzigen

De Experiabox heeft verschillende MAC-adressen. Die worden gebruikt voor de verschillende onderdelen. Het MAC-adres wat nodig is voor de internetverbinding is die van het WAN MAC Adress.

Je vindt het MAC-adres van de Experiabox door in te loggen op de webinterface, rechts onder het kopje INFORMATION.

Afbeelding van https://experiabox-bridge-modus.weebly.com/. Het gaat om het MAC Address wat in rood gekaderd is.

Om het MAC-adres van de Experiabox mee te sturen op de internetverbinding van de ASUS router:

  • Ga naar WAN
  • Plaats bij MAC Address het MAC-adres van de Experiabox. Vervang de streepjes voor :, anders zal de router het adres niet accepteren.
  • Klik op Apply

SSH activeren

De bestanden zijn het eenvoudigst op de router te plaatsen d.m.v. een SSH-verbinding. Standaard staat SSH uitgeschakeld. Zo schakel je SSH in:

  • Ga naar Administration > System
  • Selecteer bij Enable SSH: LAN only
  • Klik op Apply

Bestanden overzetten via WinSCP

Nu is het tijd om de bestanden – hier te downloaden – over te zetten. Het gaat om verschillende bestanden in verschillende mappen, in de map /jffs/.

  • .asusrouter (bestand)
  • configs (map)
    • igmpproxy.conf (bestand)
    • dnsmasq.conf.add (bestand)
  • scripts (map)
    • services-start (bestand)
    • vlan4.script (bestand)

De bestanden zijn geconfigureerd voor de ASUS RT-AC68U. Je hoeft niets aan te passen om het werkend te maken.

IP-instellingen

Deze handleiding gaat ervan uit dat het netwerk 192.168.1.0 met subnet 255.255.255.0 wordt gebruikt. Dit is standaard.

Indien het subnet waarin de ASUS RT-AC68U wordt geplaatst groter of kleiner is, dan moet het broadcastadres in dnsmasq.conf.add gewijzigd worden naar het juiste broadcastadres.

Anders kan de settopbox na uitschakeling geen verbinding meer tot stand brengen.

Scripts uitvoerbaar maken

Om de scripts uitvoerbaar te maken dienen de permissies gewijzigd te worden. Gebruik hiervoor het commando chmod.

Zorg dat de permissies overeenkomen met onderstaande tabel.

BestandsnaamPermissie
.asusrouter0555
services-start0755
vlan4.script0755

Testen

Nu is het tijd om te testen of de instellingen goed zijn geconfigureerd.

Checklist

  • Controleer of de VLAN voor Internet goed is ingevuld in de webinterface
  • Controleer of alle bestanden in de juiste mappen staan
  • Controleer of de permissies goed zijn ingesteld

Herstart de router en houdt de logs goed in de gaten. Je vindt de logs bij System Log.

Afronden

Als blijkt dat alles goed werkt, dan is het tijd om SSH weer uit te schakelen. Open de webinterface

  • Ga naar Administration > System
  • Selecteer bij Enable SSH: No
  • Klik op Apply

Veel kijkplezier!

Switch from Certbot to acme.sh

I normally use Certbot to issue and install the free Let’s Encrypt certificates. But I haven’t found a, or there is no, convenient way to issue ECC-certificates with Certbot. For that reason I switched from Certbot to acme.sh.

With acme.sh I can generate ECC certificates, without having to generate all kinds of extra files before I receive the right type of certificate.

So here’s what I did to change from Certbot issuing my certificates, to acme.sh. I use nginx as a webserver, and I have to make some changes in the config as well.

Install acme.sh

wget -O -  https://get.acme.sh | sh

Revoke the current certificate from Certbot

Next, I revoke the certificate I’m currently using from Certbot.

certbot revoke --cert-path /etc/letsencrypt/archive/blog.casakampa.nl/cert1.pem

Issue a new certificate

I use acme.sh to issue a new certificate, which will be later used by nginx to encrypt the connection between browser and server. I use an elliptic curve (ec-384) to create an ECC-certificate.

acme.sh --issue -d blog.casakampa.nl --keylength ec-384 -w /home/mvandek/blog.casakampa.nl

Change the virtual host config of nginx

nano /etc/nginx/sites-enabled/ssl.blog.casakampa.nl

There I find these rules:

ssl_certificate /etc/letsencrypt/live/blog.casakampa.nl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/blog.casakampa.nl/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/blog.casakampa.nl/chain.pem;

I changed them into:

ssl_certificate /etc/ssl/acme/blog.casakampa.nl/ecc-fullchain.pem;
ssl_certificate_key /etc/ssl/acme/blog.casakampa.nl/ecc-key.pem;
ssl_trusted_certificate /etc/ssl/acme/blog.casakampa.nl/ecc-cert.pem;

Do not restart nginx. The ‘old’ Certbot certificates are still used by nginx, so you still can connect to the website, even while the certificates are already revoked.

Now you have to create the folder in which the new certificates will be installed, and from where nginx will load the new issued certificates.

Create directory for certificates

First, create a folder called acme inside /etc/ssl/. Then, accordingly to the domain name, create a folder where the certificates will be stored. In this case, that folder will be named blog.casakampa.nl.

In short:

mkdir -p /etc/ssl/acme/blog.casakampa.nl

Install the issued certificates

The following code will install the certificate for the domain blog.casakampa.nl. It knows it’s an ECC-certificate because of the –ecc parameter. When the files are installed, nginx will be restarted to load the new certificates.

acme.sh --install-cert -d blog.casakampa.nl --ecc \
--cert-file /etc/ssl/acme/blog.casakampa.nl/ecc-cert.pem \
--key-file /etc/ssl/acme/blog.casakampa.nl/ecc-key.pem \
--fullchain-file /etc/ssl/acme/blog.casakampa.nl/ecc-fullchain.pem \
--reloadcmd "systemctl restart nginx.service"

Certbot: Renew certificate in standalone mode with nginx

When you use the Standalone mode for the validation of your certificate, you cannot use your normal webserver (Apache or, in this case, nginx). You have to use the built in webserver from Certbot.

If you want to renew your certificate and you forget to shutdown your webserver, you will get the following error during renewal:

Attempting to renew cert (example.com) from /etc/letsencrypt/renewal/example.com.conf produced an unexpected error: Problem binding to port 80: Could no t bind to IPv4 or IPv6.. Skipping
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/example.com/fullchain.pem (failure)

To solve this problem, I’ve edited the /etc/letsencrypt/renewal/example.com.conf file and added the following two lines:

pre_hook = systemctl stop nginx.service
post_hook = systemctl start nginx.service

Note: change nginx.service to apache2.service for Apache

These two lines make sure that the web server is shutdown (pre_hook) before the renewal request is done, and starts the webserver again when the renewal procedure is succesful (post_hook).

When run again, you’ll get the following result:

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/example.com/fullchain.pem (success)

Flash Sonoff Basic met Arduino IDE

Benodigde software:

  • Arduino IDE
  • ESPEasy

Stappenplan

Arduino IDE installeren en configureren

  1. Installeer Arduino IDE van Arduino.cc (kan .exe of .zip. Laatste optie betekent een standalone installatie.)
  2. Download de stable release van ESPEasy
  3. Unzip ESPEasy
  4. Kopieer de inhoud van de map Libraries in de map Source, uit de geünzipte map van ESPEasy, naar de map libraries in de programmamap van Arduino.
  5. Open Arduino IDE
  6. Open File > Preferences
  7. Plaats de URL http://arduino.esp8266.com/stable/package_esp8266com_index.json in het veld Additional Boards Manager URLs:
  8. Druk op OK
  9. Ga naar Tools > Board: “Arduino/Genuino Uno” > Boards Manager
  10. Zoek naar ESP8266.
  11. Installeer esp8266 by ESP8266 Community, versie 2.3.0.

ESPEasy compileren en uploaden

  1. Ga naar File > Open
  2. Navigeer naar de map ESPeasy > Source > ESPeasy
  3. Open het bestand ESPEasy.ino
  4. Ga naar Tools > Board “Arduino / Genuino Uno”
  5. Selecteer Generic ESP8266 Module
  6. Ga naar Tools en controleer de volgende opties
    1. Flash Mode: DOUT
    2. Flash Size: 1M (128K SPIFFS)
    3. Port: Betreffence COM-poort
  7. Sluit de Sonoff aan op de USB naar TTL controller, maar laat de 3.3V aansluiting los
  8. Druk de zwarte knop in, en sluit vervolgens de 3.3V aan
  9. Ga naar Sketch > Verify/Compile
  10. Ga naar Sketch > Upload
  11. Koppel na een voltooide upload de USB naar TTL controller los. Wacht 5 seconden en sluit deze weer aan.

ESPEasy configureren

Een wifinetwerk genaamd ESP_0 verschijnt

  1. Maak verbinding met ESP_0
  2. Vul het wachtwoord in: configesp
  3. Wanneer succesvol verbonden, wordt het IP 192.168.4.2 toegekend
  4. Navigeer naar http://192.168.4.1
  5. De switch is nu klaar voor configuratie

 

Remove expired WordPress Transients with WP-CLI

WP-CLI can be used to perform all kinds of tasks on your WordPress website. I use it to regularly clean my database of expired transients via a Linux cronjob. By using WP-CLI, I can perform this task safely and automatically!

Note: this can only be done when you have shell-access to the webserver you are managing.

First you need to install WP-CLI. How to do that is explained here. After you’ve installed WP-CLI, you have to find the folder of the WordPress website.

In my case the folder of the website is located at:

/home/mvandek/blog.casakampa.nl/

To remove the expired WordPress Transients from the database of this website, I use the following command:

/usr/local/bin/wp --path=/home/mvandek/blog.casakampa.nl transient delete --expired --allow-root

The following parameters are used:

  • –path= – this is the folder where WordPress is installed
  • transient – tells WP-CLI to use the Transient module
  • delete – tells WP-CLI to delete the Transients in the database
  • –expired – tells WP-CLI to only delete the expired Transients. These aren’t automatically removed and thus can stay in the database while expired
  • –allow-root – normally you have to run this command from the user that manages the website. I add this so that I can run this command from the shell

I use the path /usr/local/bin/wp instead of the command wp. By doing this I’m sure I won’t get any errors when executing this task.

Next, I have to determine when I want to run this cronjob. This can be executed at the following moments:

  • @hourly – every hour of every day
  • @daily – every day at 0:00
  • @weekly – everey sunday at 0:00
  • @monthly – every first day of the month at 0:00
  • @yearly – every frist day of the first month at 0:00
  • @annualy – same as @yearly

So, to be sure that the removal of the expired transients is done regularly, I chose to use @daily.

The command to remove the expired Transiens will be:

@daily /usr/local/bin/wp --path=/home/maartenvandekamp/www.maartenvandekamp.nl transient delete --expired --allow-root

Add this line of code to crontab via the following command:

crontab -e

Add the line to this file and leave the editor.

Crontab will now make a new job that will be executed every day at 0:00, and will send the output to the root user.

If you don’t want to be notified of the output, you have to add the following code after the origininal command

> /dev/null 2>&1

The complete line will be:

@daily /usr/local/bin/wp --path=/home/maartenvandekamp/www.maartenvandekamp.nl transient delete --expired --allow-root > /dev/null 2>&1

Bye Bye Google AMP

Toen Google AMP geïntroduceerd werd leek het heel mooi. Snelle laadtijden voor lichte pagina’s waardoor er misschien meer mensen naar de website zouden komen. Ook ik deed eraan mee met www.maartenvandekamp.nl. Tot vandaag, want ik heb besloten om Google AMP niet meer te ondersteunen.

De belangrijkste reden is omdat de pagina’s door Google gecached worden, en ik erachter kwam dat de tracking-code die aan elke pagina werd toegevoegd, niet juist in AMPHTML werd weergegeven. Daardoor liep ik dus een correcte registratie van mijn bezoekers mis. Niet dat ik hier geld mee verdien, maar ik wil wel graag weten welke content veel wordt bezocht.

Wat ik heb gedaan:

Stap 1

De volgende code heb ik aan mijn thema toegevoegd in het bestand functions.php:

add_filter( 'amp_frontend_show_canonical', '__return_false' );

Deze code werkt alleen wanneer de plugin AMP-WP geïnstalleerd en ingeschakeld is!
Stap 2

In het configuratiebestand van Nginx voor de website van maartenvandekamp.nl de volgende code toegevoegd:

location ~ /amp/$ {
 rewrite ^(.*/)amp/$ $1 permanent;
}

Wat deze twee stukken code doen zijn:

Stap 1: Een WordPress filter benutten in de AMP-WP plugin waarin wordt aangegeven dat <amphtml> niet meer getoond moet worden.

Stap 2: Elke URL die eindigt op /amp/ verwijzen naar de niet-AMP url. Hierdoor indexeert Google weer de normale webpagina’s die ik ooit zo goed mogelijk heb geoptimaliseerd voor mobiele apparaten.

Mogelijke nadelen van het uitschakelen van AMP zijn dat mijn website minder hoog in de zoekresultaten komt te staan. Dat neem ik voor lief, want nu heb ik weer volledige controle over de content en kan ik beter registreren welke delen van de website bezocht worden.

De komende maanden laat ik de plugin AMP-WP nog actief zodat /amp/ nog aan de URL wordt toegevoegd. Zo weet ik zeker dat de indexatie van de AMP naar de niet-AMP URL goed verloopt.

Windows 10 – beperk inlogtijden voor lokale accounts

In voorgaande Windows versies was Ouderlijk Toezicht een prachtig programma waarin per account kon worden aangegeven wanneer wel en niet mocht worden ingelogd. In Windows 10 is dat aangepast. Nu moet elk account inloggen met een Microsoft-account, en zijn de mogelijkheden beperkter dan bij het gebruik van Ouderlijk Toezicht.

Het is gelukkig mogelijk om de inlogtijden via de command prompt alsnog te wijzigen. Hoe dat moet, is op deze Engelstalige pagina te lezen: https://www.howtogeek.com/250224/how-to-set-time-limits-for-a-regular-account-in-windows-10/

Backup emailaccounts with Zimbra zmmailbox

The following code makes it possible to loop through email addresses saved in the file /home/maarten/emailaccounts.txt.

#!/bin/bash

for i in $(cat /home/maarten/emailaccounts.txt);

do zmmailbox -z -m $i getRestURL "//?fmt=tgz" > /backup/$i.$(date +%d-%m-%Y).tgz

done

For now the addresses have to be added manually to the file emailaccounts.txt, but with the zmprov command it’s possible to generate a list of accounts, which can also be used as a source for accounts that have to be exported.

Make sure you have a folder backup in the root of your server (mkdir /backup), and it is writable for the Zimbra user (chown zimbra:zimbra /backup).

A better version of this backup script can be found here.

Keep WordPress comment_agent and comment_user_IP empty with hooks

WordPress saves all kinds of information when someone leaves a comment on your blog/website. Two pieces of information I don’t need from someone who comments on an article are the IP-address of the author and the User Agent of the browser they used to place the comment.

pre_comment_* hooks

WordPress has pre_comment_* hooks which can be used to alter data before it’s put into the database.

I used the following two hooks:

pre_comment_user_ip

This hook filters the comment author’s IP before it is set, so this can be used to alter the IP-address before it’s saved in the database.

// Don't log IP addresses of comment authors.
add_filter( 'pre_comment_user_ip', '__return_zero' );

The filter uses the function __return_zero, which does exactly as it says: the comment_user_ip is set to 0.

Clean up already saved IP-addresses

To clean up the already saved IP-addresses, you execute the following SQL-query (after you made sure you have made a full backup of the database) via phpMyAdmin to your WordPress database:

update wp_comments set comment_author_IP ='' ;

pre_comment_user_agent

This hook filters the comment author’s browser user agent before it is set, so this can be used to alter the User Agent before it’s saved in the database.

// Don't log User Agents of comment authors.
add_filter( 'pre_comment_user_agent', '__return_empty_string' );

The filter uses the function __return_empty_string, which returns an empty string before the data is saved into the database, thus keeping the database clean from unneeded information.

Clean up already saved User Agents

To clean up the already saved User Agents, you execute the following SQL-query (after you made sure you have made a full backup of the database) via phpMyAdmin to your WordPress database:

update wp_comments set comment_agent ='' ;