Press "Enter" to skip to content Posts

Home Assistant (docker) on QNAP

I was curious to see if the installation of Home Assistant in my new QNAP was feasible and I have been very surprised by how easy the task has been.

I have only test this procedure in my QNAP TS-453be, with the latest versions of QTS and Container Station ( and 2.0.117 respectively), I’m not sure if it would work on different hardware or with different versions of software, although in the newer versions with docker support it should be quite straightforward.

I will show two methods to obtain the same result, one through the CLI and another from the QTS graphic interface. First of all there is a small requirement. We need access to a directory outside the container where we will store the configuration of Home Assistant to not lose it if we update the container, in my case this directory is a share on the nas called ‘/Container/hass_config’. Hands on with the first method, in my opinion the most simple, connect to the nas by ssh as administrator and execute the following command:

docker run --init -d --name="home-assistant" -v /Container/hass_config:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant:latest

Neat and easy, isn’t it? After a while, you can access your Home Assistant instance in the url ‘’, do not forget to put the ip of your nas instead of the x‘s.

And now the GUI method, using Container Station from your nas, here are the steps to follow:

  • Open ‘Container Station’ and select create.
  • Search for “homeassistant”, find the ‘homeassistant/home-assistant’ image on the Docker Hub results tab and click ‘Create’.
  • Select version, and set the name and resources for the container as per your requirements.
  • Under ‘Advanced Settings -> Environment’ create a variable named tz with your timezone as value (e. Europe/Madrid).
  • Under ‘Advanced Settings -> Network’ select Host as Network Mode.
  • Under ‘Advanced Settings -> Shared Folders’ you should add a directory from your nas (host) as stated before or create a new one, use /config as mount point.

And that’s it, some time after clicking ‘Create’ you should be able to access your Home Assistant instance in the url ‘’, replace the ip of your nas with the x‘s.

In order to update your Home Assistant instance, just remove container and image and reinstall it again, configuration should be kept in ‘/Container/hass_config’.

Leave a Comment

Tcpdump over ssh and wireshark

Here you have a very useful command for when you want to analyze traffic remotely over ssh using wireshark.

ssh root@ tcpdump -i any -U -s0 -w - 'not port 22' | wireshark -k -i -

The idea is to run tcpdump on the remote server over ssh, send that capture in real time through this encrypted connection and view it on our local computer with wireshark, a graphical package inspector with many interesting features.

Leave a Comment

How to Install PowerDNS and PowerDNS-Admin on Debian 9

Hi! This is a script-guide to install Powerdns (authoritative) and Powerdns-Admin in Debian 9. This is a quick way, see instructions below, here is the commented code for the impatient.


# get script absolute path
MY_PATH="`dirname \"$0\"`"
MY_PATH="`( cd \"$MY_PATH\" && pwd )`"
if [ -z "$MY_PATH" ] ; then
  exit 1

# upgrade system and install dependencies
apt-get update && apt-get -y upgrade
apt-get -y install software-properties-common dirmngr
apt-get -y install git python-pip

# install and prepare last stable mariadb version
apt-key adv --recv-keys --keyserver 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] stretch main'
apt-get update && apt-get -y install mariadb-server # provide an strong password when prompted
mysql -u root -p < ${MY_PATH}/sql01.sql # provide previously set password

# install powerdns and configure db parameters
apt-get -y install pdns-server pdns-backend-mysql # answer dbconfig-common No when prompted
vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf # db configuration

# install dnsutils for testing and finally PowerDNS-Admin
apt-get -y install python3-dev dnsutils
apt-get -y install -y default-libmysqlclient-dev python-mysqldb libsasl2-dev libffi-dev libldap2-dev libssl-dev libxml2-dev libxslt1-dev libxmlsec1-dev pkg-config
curl -sS | sudo apt-key add -
echo 'deb stable main' > /etc/apt/sources.list.d/yarn.list
apt-get -y install apt-transport-https # needed for https repo
apt-get update 
apt-get -y install yarn
git clone /opt/web/powerdns-admin
cd /opt/web/powerdns-admin
pip install virtualenv
virtualenv -p python3 flask
. ./flask/bin/activate
apt-get -y install libmysqlclient-dev
pip install -r requirements.txt
mysql -u root -p < ${MY_PATH}/sql02.sql
vi # db configuration
export FLASK_APP=app/
flask db upgrade
flask db migrate -m "Init DB"

# install/update nodejs, needed to use yarn
curl -sL | sudo -E bash -
apt-get install -y nodejs
yarn install --pure-lockfile
flask assets build

# create systemd service file and activate it
cp ${MY_PATH}/powerdns-admin.service /etc/systemd/system/
systemctl daemon-reload
systemctl start powerdns-admin
systemctl enable powerdns-admin

# install nginx and configure site
apt-get -y install nginx
cp ${MY_PATH}/powerdns-admin.conf /etc/nginx/sites-enabled/
nginx -t && service nginx restart

# activate powerdns api, change api-key if needed
echo 'api=yes' >> /etc/powerdns/pdns.conf
echo 'api-key=789456123741852963' >> /etc/powerdns/pdns.conf
echo 'webserver=yes' >> /etc/powerdns/pdns.conf
echo 'webserver-address=' >> /etc/powerdns/pdns.conf
echo 'webserver-allow-from=,::/0' >> /etc/powerdns/pdns.conf
echo 'webserver-port=8081' >> /etc/powerdns/pdns.conf
service pdns restart

# now go to server_name url and create a firt user account that will be admin
# log in
# configure api access on powerdns-admin
# enjoy

Installation notes

You can execute the executable file inside the zip file, or execute lines one by one from code above. Whatever method you use you should read this notes carefully in order to fully understand what is going on. I assume that yo have a minimum linux knowledge and that you are comfortable with the shell and command line utilities.

  1. Download and uncompress anywhere in the server, then cd into pdns folder.
  2. Edit sql01.sql and modify the second line to set a secure password instead of the default one ‘mypassword’.
  3. Edit sql02.sql and modify the second line to set a secure password instead of the default one ‘mypassword’.
  4. Edit powerdns-admin.conf and modify the value of server_name to match the fqdn we want our pdnsadmin be served from.
  5. Execute script:
    • Provide mariadb root password to execute sql01.sql when prompted.
    • Edit /etc/powerdns/pdns.d/pdns.local.gmysql.conf db settings to match this ones:
      • user: pdnsuser
      • password: <the one provided in step 2>
      • host: localhost
      • db name: pdns
    • Provide mariadb root password to execute sql02.sql when prompted.
    • Edit /opt/web/powerdns-admin/ db settings to match this ones:
      • user: pdnsuser
      • password: <the one provided in step 2>
      • host: localhost
      • db name: pdns
  6. Enter web interface (domain provided in step 4) and click on create account to create the first account, thal will be an admin account.
  7. Log in into pdnsAdmin with the newly created account.
  8. Configure pdns api and pdns key, and the one provided at the end of the script.
  9. Enjoy!