Motioneye + IPv6


MotioneyeOS + IPv6

by Craig Miller

Motioneye is an opensource software project which turns your SBC (Small Board Computer) into a video security system with support for both IPv4 Cameras, as well as directly attached USB cameras.

It even includes a all-in-one prepackaged distribution called MotioneyeOS. Just burn to an SD card, insert into your SBC, and you are off and running. The downside is that it does not support IPv6.

Bringing IPv6 to Motioneyeos

Thanks to a bug raised in 2018, the author of Motioneye enabled IPv6 in the kernel distributed and burned to an SD card. That was the first step. But in order to manage the SBC via IPv6 requires a bit more work.

One can follow the instructions in the bug 779, but in order to make the required change to one must first get the source. MotioneyeOS does not include the *py files, only the byte-compiled pyc files.

Using uncompyle6 the Python decompiler

Fortunately, there is another open source project which does an excellent job of decompiling pyc to py files. uncompyle6 I installed it on one of my Alpine Linux containers with pip. I'll call this system remote_host in this article.

apk add python2 py2-pip
pip install uncompyle6

MotioneyeOS Distro limitation

The Distro is convenient to use, but a downside of the MotioneyeOS distro is that there aren't any package management tools on the SD card. So one can't install uncompyle6 directly on the SBC.

In order to change files on the root file system, one needs to remount it in rw mode

mount -o remount,rw /

Fortunately, the distro does include openssh, and it is possible to scp files off and back onto the SBC. First one needs to enable IPv6 for ssh. Edit /etc/ssh/sshd_config and add the line:

ListenAddress ::

and restart sshd

/etc/init.d/S60sshd restart

Now you should be able to ssh in on the IPv6 address of MotioneyeOS. How did you get the address. The easiest way is to make a note of it while you were in editing the sshd config file with the ip addr command.

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether b8:27:eb:6c:02:88 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2001:db8:8011:fd44:ba27:ebff:fe6c:288/64 scope global dynamic 
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fe6c:388/64 scope link 
       valid_lft forever preferred_lft forever

Since I run a DNS server for the machines in my house, I just added a AAAA record with the IPv6 GUA (Global Unique) address.

Now that we have enabled IPv6 for ssh we can copy the settings.pyc file onto a system (for me a linux container) which has uncompyle6 installed.

Decompiling settings.pyc

While you are ssh-d into the MotioneyeOS system, just scp the file off to the remote_host.

cd /usr/lib/python2.7/site-packages/motioneye/
scp settings.pyc remote_host:

In another terminal window, ssh into the remote_host with uncompyle6 installed and cd into the directory you scp'd the settings.pyc file into.

Running uncompyle6 is easy. Like all good programs it has help.

$ uncompyle6 --help

  uncompyle6 [OPTIONS]... [ FILE | DIR]...
  uncompyle6 [--help | -h | --V | --version]

  uncompyle6      foo.pyc bar.pyc       # decompile foo.pyc, bar.pyc to stdout
  uncompyle6 -o . foo.pyc bar.pyc       # decompile to ./foo.pyc_dis and ./bar.pyc_dis
  uncompyle6 -o /tmp /usr/lib/python1.5 # decompile whole library

To decompile settings.pyc to just run:

uncompyle6 -o . settings.pyc

Now there should be a file in that directory.

Enabling IPv6 in

While logged into the remote_host with uncompyle6 installed, might as well edit the file to enable IPv6. Look for the line:


and change it to:


Save, and now we'll put the file back on to the MotioneyeOS SBC.

Almost there

ssh back into the MotioneyeOS SBC and cd into the directory where the settings.pyc file lives. I moved the settings.pyc file to a back up to ensure that the python compiler would create a new pyc file from the modified file.

cd /usr/lib/python2.7/site-packages/motioneye/
scp .
mv settings.pyc settings.pyc.bak

Lastly, comment out the LISTEN line on the /data/etc/motioneye.conf file, as it will over-ride the file.

It is possible to just restart the web management service, but at this point it probably easiest to just reboot the SBC.


Now IPv6 is enabled and listening!

Now point your browser at the MotioneyeOS SBC (you did create an AAAA record in your DNS, right?) and you are now managing MotioneyeOS via IPv6!

11 December 2020

updated 21 March 2021