Dynamic DNS using dynv6.com and DD-WRT

As of DD-WRT v3.0-r33772 (16/11/2017), DD-WRT's DDNS settings do not offer presets for dynv6.com. Unfortunately, the instructions for the »custom« settings of DD-WRT's DDNS feature are even more opaque than inadyn's man page. After some trial and error, I ended up with the following working setup.

DDNS Service
Custom
DYNDNS Server
dynv6.com
Username
user
Password
password
Hostname
your host name
URL
/api/update?ipv4=auto&ipv6=auto&token=your token&hostname=

Note that the username and password settings aren't used by dynv6.com, but they cannot be empty because DD-WRT then refuses to start the inadyn service.

You can find out the value for token by logging into your dynv6.com account. The settings are chosen to update the IPv4 or IPv6 address to the address from which the request is received. I have not investigated how to update both protocols at the same time.

The host name you enter into the corresponding field is automatically appended to the URL, which is why that parameter comes last without a value.

If you would like to see what's happening, you can add --verbose 5 to the »Additional DDNS Options« and the log file shown at the bottom of the page will contain more information.

Windows 10 setup steps

Remove OneDrive:

C:\Windows\SysWOW64\OneDriveSetup.exe -uninstall
Set HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\System.IsPinnedToNameSpaceTree and HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\System.IsPinnedToNameSpaceTree to 0.
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
"System.IsPinnedToNameSpaceTree"=dword:00000000

[HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
"System.IsPinnedToNameSpaceTree"=dword:00000000

Run Protec'tor.

Ad filtering setup for DD-WRT

In order to set up ad filtering by host blocking on DD-WRT, you can create a cron(1) script to download a hosts file and point dnsmasq(1) to it.

The first step is accomplished by a crontab entry in Administration, Cron like the following (line broken for readability). Note that this file is in cron.d format, i.e. the sixth field is the user name and the command is the seventh field.

0 0 * * * root mkdir -p /tmp/adhosts;
    i=0;
    for url in "http://hosts-file.net/download/hosts.txt";
    do
        /usr/bin/curl -s "$url" > /tmp/adhosts/$i;
        i=$((1 + i));
    done;
    kill -hup $(cat /var/run/dnsmasq.pid)

You can add any number of files to download, but since cron(1) does not support line continuation you will have to write the entire script in one line (or store it somewhere in the filesystem).

In order for dnsmasq to pick up the list, the following setting is needed in Services, DNSMasq:

addn-hosts=/tmp/adhosts

PHP and MariaDB on OpenBSD

First, create a /etc/httpd.conf configuration file.

server "default" {
        directory index "index.php"
        listen on * port 80
        location "*.php" {
                fastcgi socket "/run/php-fpm.sock"
        }
}

Next, enable and start httpd.

# rcctl enable httpd
# rcctl start httpd

Then install PHP.

# pkg_add php

In order for httpd to be able to run PHP scripts, the PHP FastCGI server must be enabled and started.

# rcctl enable php70_fpm
# rcctl start php70_fpm

As a test, accessing your server from a browser should work after creating a file /var/www/htdocs/index.php with the following contents:

<?php
phpinfo();

Don't forget to delete this again after testing.

# rm /var/www/htdocs/index.php

Next, install and configure MariaDB.

# pkg_add mariadb-server php-pdo_mysql

MariaDB requires some initial configuration.

# rcctl enable mysqld
# rcctl start mysqld
# mysql_install_db --user=_mysql
# mysql_secure_installation

This must be done before changing the MariaDB socket (below).

Edit the file /etc/my.cnf and change the socket variable to /var/www/run/mysql/mysql.sock in both the [client] and [server] sections in order to make it accessible to processes running with chroot inside /var/www. While you're here, you might want to enable skip-networking if you don't intend to access your database remotely.

# rcctl restart mysqld

Activate the PDO database driver.

# ln -s ../php-7.0.sample/pdo_mysql.ini /etc/php-7.0/

Configure the PDO database driver accordingly to connect to the database at the correct socket. Note the missing /var/www prefix due to the chroot done by php70_fpm!

# echo "pdo_mysql.default_socket=/run/mysql/mysql.sock" >> /etc/php-7.0/pdo_mysql.ini
# rcctl restart php70_fpm

Changes to the PHP configuration may require restarting the FastCGI server.

As pointed out in the PHP manual, if your web app needs to do DNS lookups it's going to need a copy of your /etc/resolv.conf and /etc/services.

# mkdir /var/www/etc
# cp /etc/resolv.conf /etc/services /var/www/etc

And likewise, in order to enable SSL connections:

# cp -R /etc/ssl /var/www/etc/

Then install any additional PHP modules your apps require.

# pkg_add php-curl php-zip
# rcctl restart php70_fpm

OpenBSD on Hyper-V

Installing OpenBSD on Hyper-V shouldn't really be an issue since the OS even contains specific driver for virtualised drives (hvs(4)) and network cards (hvn(4)).

However, I did not succeed installing OpenBSD 6.2 on Hyper-V because it hung while attaching the disk driver at the line

hvs0 at hyperv0 controller 1: ide
This occurred both when attaching the disk through an IDE and SCSI controller. After disable hvs in the user kernel configurator the kernel boots.

OpenBSD 6.1 recognises the attached disk as a standard IDE drive as opposed to a virtualised hvs drive and works.

The standard network adaptor is not recognised by OpenBSD 6.1, so it is necessary to use the compatibility network adaptor.

Note that according to a remark in Microsoft's instructions for creating an OpenBSD disk for Azure, only »fixed« disk images are supported. Since the »Create VM« wizard of the Hyper-V manager creates dynamic disk images by default, it makes more sense to choose the option to »create and attach a disk image later« and then creating a fixed disk manually.

Installing and removing python packages on macOS

Since python on macOS comes without the pip package manager, I was wondering how to install and remove packages.

As it turns out, there's an older »package manager« called easy-install that can be used to install, but not remove packages.

If you're happy installing packages system-wide, i.e. inside /Library/Python on macOS, you can run

# easy_install pyyaml

Installing into the user's package directory in $HOME/Library/Python can be done by

$ easy_install --user pyyaml

Removing packages isn't quite as straightforward as easy_install doesn't offer a command to do so. The manual (linked above) suggests to run

# easy_install -mxN pyyaml
prior to deleting a package, but I have not looked into what that entails.

Essentially, all that seems to be necessary is to delete the corresponding line from the package database, located at /Library/Python/2.7/site-packages/easy-install.pth, for example, and then delete the .egg file (a ZIP).