Quick and easy OpenVPN using Docker Containers

OpenVPN logoI like OpenVPN, it is free, moderately secure, low overhead, and now with container technology, I total snap to setup in the cloud. Many DD-WRT and Open-WRT based routers support OpenVPN out of the box as well making it a good choice for personal use.

I’m here in a coffee shop in Vietnam using my OpenVPN docker instance presently and it’s been working swimmingly. Also used it in Texas, Idaho and Mexico without issue.

After congress voted in March 2017 along party lines to allow the collection and sale of your internet browsing history (previously banned) I decided to look in to OpenVPN again. OpenVPN can be a bit of a hassle to setup on a local server behind a firewall, but hosted in the cloud is relatively easy. I moved my linode over to their German datacenter (Germany has awesome privacy laws) and spun up a VPN server in just minutes using docker.

This is what I ended up doing as a simple trial. It’s worked so well so far I haven’t had any reason to change things.

Continue reading

Posted in docker, linux, travel | Tagged , , , , | Leave a comment

Using GCE’s new free-tier micro VPS for fun and profit

Google’s Cloud Engine product, GCE allows developers a couple hundred dollars worth of credits, but more importantly, they’ve setup an “always free” tier VPS, the f1-micro (1 vCPU, 0.6 GB memory). Now, there’s not a whole lot you can do with 600mb of RAM in today’s world, but I decided to give it a go.

Since we’re going to plug a couple of docker containers in to this machine, I went with my favorite, jwilder’s nginx reverse proxy. For example if you have three domains, livelylobster.us, treeoctop.us and plutovir.us and you would like to run three blogs from here. First, spin up your nginx reverse proxy:

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy

Now your VPS is listening on port 80 for all connections. Go to your registrar and make sure your A records are pointing at your VPS, this could take from minutes to a day depending on who is your DNS provider. From here, due to how well this containerized reverse proxy system works, we just spin up blogging containers with the correct environmental variables in the docker run command.

-e VIRTUAL_HOST=livelylobster.us

See it in action, spin up a blog at livelylobster.us:

docker run --name ghost --restart always --expose 2368 -v /var/livelylobster/ghost:/var/lib/ghost -e VIRTUAL_HOST=livelylobster.us -d ghost

Ok while that is spinning up, start a second blog, this time for plutovir.us using the same environmental variable method described above, volume mounting from a different location to keep them seperate:

docker run --name ghost-pv --restart always --expose 2368 -p 2369:236 8 -v /var/plutovirus/ghost:/var/lib/ghost -e VIRTUAL_HOST=plutovir.us -d ghost

After the whole Evernote wants to read your notes snafu I’ve been looking for a replacement. The open source alternatives leave a lot to be desired. Livelylobster has been put in private mode, I’ve been experimenting with using Ghost as a markdown specific notes system that also allows image uploads. One of my biggest beefs with Evernote, besides the privacy issue, is that it always preserves font styling etc which makes it painful to work with directly. It’s a work in progress, but with some minor changes may make a suitable alternative.

Anyways, at this point you should be able to browse to http://livelylobster.us and http://plutovir.us and view your handiwork.  To properly set them up for the first time, you will likely need to go to http://hostname/ghost/

The big takeaway here is that containers can be very small or actually quite large, depending on how they’re setup. The micro VPS has but only 600mb ram; obviously there’s some system overhead, the nginx proxy only uses 10MB ram which is about average from what I’ve seen from truly lightweight containers. Ghost on the other hand uses somewhere between 110MB and 175MB typically. That’s pretty heavy when you only have 300-350MB RAM to work with. Performance suffers considerably at the micro end of the VPS scale. At this point I’d consider a static website renderer to cut down on memory usage and improve overall performance, something like Jekyll or Hugo. It requires a little more pipeline to achieve this but you get the benefit of making it more modular, keeping your content in source control, and this is sort of the direction everything is headed anyways. Going to a static renderer should get you down below 30MB per container, giving you more bandwidth to standup additional services or accept many more connections.

The other thing not covered here, but supported, is enabling letsencrypt to allow full trusted SSL between clients and your web server(s). If you’re already on Kubernetes you can set it up that way. That’s a story for another time.

Posted in computing, docker, kubernetes, linux | Tagged , , , , , , , , | Leave a comment

Installing Golang (go) on the Raspberry Pi 3

As of Golang 1.6 they are distributing ARM v6 versions of the compiled binary. So now it’s simple:

Simply

wget https://storage.googleapis.com/golang/go1.7.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.7.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin

export GOPATH=$HOME/go

Posted in computing, linux, robot | Tagged , , , | Leave a comment

More microcontrollers, ESP8266, Raspberry Pi A+

ESP8266 size comparisonI have been working on electronics a bit more, I thought I would write up what I have been working on.

Most recently I have been working with NodeMCU on the ESP8266. The goal is to have a “captive wlan” with a message board. The ESP8266 is a neat little 80mhz microcontroller that costs about $4 and uses about 60ma of power @ 2.5-3.5v and perhaps most importantly, has a fairly strong 2.4ghz wifi antenna attached. It also has about 3.4MB of avalible flash memory, although that’s over shadowed by the meager ~64KB of RAM. It can run as an AP (wifi access point) or a client, or both at the same time, doing one of many things, such as a wifi bridge, or create a chain of wifi bridges.

NodeMCU is interesting in that it runs a version of Lua, so I have been learning that. This is psuedo-embedded programming so things like “web server” have big chunks of http protocol hard-coded in to the program itself, hard-coded exceptions, etc etc. There are no ini, xml, config files since everything in this tiny world of 96KB-RAM is purpose built – there are no multi-taskers here – variables take up too much space. I definitely see why someone ported the ESP8266 over to the Arduino environment.

So the plan is to attach the ESP8266 running NodeMCU, and then also have a DNS server that points all requests back to the webserver that’s also running locally. Luckily someone has already begun the first step and written that, here’s the github link. He’s using a custom firmware with the DNS stuff turned on. It looks like he’s using 0.9.5 which uses about 16KB more ram, and they’ve added this feature in 0.9.6, but he hasn’t reconciled the differences as of this writing.

Anyways, it seems like it should be fairly straightforward to rip out the basic html games, and replace it with a sort of form post method, which then writes to the top of a file, and then the “server” reads from the top of the file and feeds it in to a CSS-formatted “wall” of sorts. And then also probably a cleanup script that moves older posts to a 2.html, and every 10KB or so worth of text, adds an additional N.html, and if N-100 exists, delete n-100.html.

The ultimate idea would be to have an ESP8266 running off of a 26650 or pair of 18650s, charged via a 5v 500ma solar panel facing south, with a 5v->4.2 lipo/li ion charging circuit (with 2.7v cut-out), and then an LDO down to 3.3v regulated. Supposedly the ESP8266 will run for 1-2 days on an 18650 and you only need about 3 hours of direct sunlight to fully charge the 18650, so I am thinking a 4000mah 26650 should last 2 full days between charges.

Anyways, it’s a neat idea. A self contained, anonymous, community message board that is self powered. The whole thing could fit inside of a waterproof junction box with a neodymium magnet, and then put a blob of epoxy on the back so it becomes permanent and stick it to the back of an east-facing street sign, so that the solar panel is west-facing. Given 1000 charge-discharge cycles it could, in theory last between three and six years.

I was able to flash the ESP8266 over the weekend, I’ve become quite proficient at it. I wrote a thank you note over at the ESP8266 forum. It turns out if you over-volt any part of the ESP8266 it has bad effects on the NAND flash memory (winbond 4mb module) and scrambles the data and also the firmware. Re-flashing the old AI Thinker 0.9.5 SDK firmware seemed to fix most of the problems. Apparently if you are not able to send data, but you’re getting garbage data back from the ESP8266, that means you should just go ahead and flash, even if you can’t decode the data (I tried all available baud rates, no luck). Flashing firmware direct over serial and pulling pins high/low to the power rail(s) was a new experience for me. I definitely feel much closer to the hardware now than I ever did with an Arduino.

Flashing the ESP8266 with NodeMCU 0.9.6

Anyways this is what I wrote, for future generations:

Anyways, this is what worked for me.

I am flashing direct from a raspberry pi A+ (3.3v serial logic level) to an ESP-12

This is what worked for me, building on top of your instructions. You’ll have to make sure you have esptool and picocom installed, which probably requires pySerial.

Rpi GPIO 14 (pin 08) -> esp GPO RX
Rpi GPIO 15 (pin 10) -> esp GPO TX
Rpi GND (pin 06) -> esp GND

ESP:
VCC -> 3.3v power source
VCC -> GPIO 2
VCC -> GPO CH_PD (*)

GND -> GND power source
GND -> GPIO 0

To flash
Disconnect VCC -> 3.3v power source
Disconnect VCC -> GPO CH_PD (*)
Connect GND -> GPIO 0
VCC -> 3.3v power source

Run “sudo python esptool.py –port /dev/ttyAMA0 write_flash 0×00 nodemcu-master-7-modules-2015-09-06-22-54-05-integer.bin”

IMMEDIATELY (~0.5 seconds) Connect VCC -> GPO CH_PD (*)

Should flash
Disconnect VCC -> 3.3v power source
Disconnect GND -> GPIO 0
Connect VCC -> 3.3v power source

Run “sudo picocom /dev/ttyAMA0 –b 9600 –omap crcrlf –imap crcrlf ”

I was NOT able to re-flash NodeMCU 0.9.6 over top of itself. I had to reflash the AI Thinker 0.9.5 SDK (stock) firmware. Reflashing the old AI Thinker 0.9.5 SDK firmware “revived” a bunch of previously “bricked” ESPs.

I will have to get in to how POST messages work, as they have to be manually handled by the Lua script. That’s a task for tomorrow. And then also coming up with CSS to frame everything with. I found some example code I think I can leverage off of and go from there.

I did manage to fry one of my ESP8266, on my HP dual power supply the knobs allow you to go from 0-20v, and the knobs rotate in the opposite direction as the analog voltage meter sweeps. As I went to test to see how the ESP8266 recovers from voltage cutout, I dialed it to “0″, and was agape when I saw the needle bury at 20v instead of 0v. oops. To my suprise, I was able to massage it back to life and flash it a couple of times, but every time I tried writinga 56kb file to the NAND memory, it would corrupt and become unresponsive. Maybe I can set it up as a temp sensor or something. Who knows.

This is the death scream of a serial device when you accidentally feed 20 volts directly in to it’s puny 3 volt brain. ( “AhhA!!)!!!!!1ù” ) RIP #ESP8266  I was able to reflash it and get it to boot, but the flash memory wouldn’t hold for very long. I think the NAND is more voltage-sensitive than the CPU.

This is the death scream of a serial device being overvolted

One idea I had for a temp sensor was, since with NodeMCU you can modify the SSID so easily, read the temp sensor, and set the SSID as something like “T_85F_H_54P” where 85F is the temp and 54P is the relative humidity. That way anyone within broadcast range can check the temp without having to login to the device. I guess you could encode another 24 bytes of information in the MAC address too but that’s not human readable.

Oh right, I’ve been using my Raspberry Pi A+ to talk to the ESP8266. The Pi and the ESP both have 3.3v logic level so no converter is necessary, just the RX, TX pins and a common ground. I’ve been using picocom to monitor the serial output, and a combination of esptool to burn firmware, and then luatool and nodemcu-uploadertool to upload files. I like luatool because you handle the serial port in the commandline rather than digging around in the .py file to set it, but the uploadertool supports unlimited(?) file size (largest I’ve done is I think 100kb?) and more importantly multi-file upload. It’s not nearly as fancy as the ESP SDK on windows, but I like that I can talk to the Pi and the ESP over wifi from anywhere in the house, and I’m not tied to a workbench somewhere with the ESP’s fairly fragile flashing setup (I’m just using breadboard and jumpers).

I also have a Raspberry Pi based robot using bluetooth and wifi and motor controller on a modified Shrimpbot chasis. I will have to put up a seperate post about that when I get a chance.

Posted in computing, linux, Mechanical, robot | Tagged , , , , , , | Leave a comment

Tinkering with Microcontrollers, Arduino + Beaglebone, frustrations

Two primary lessons I’ve learned

  1. Don’t work on the wiring aspect of electronics past 1am or so. The chances of you shorting something out approach 100% as you get closer to 3am
  2. Servos have more torque than you think and consume a ton of instantanious amperage

I’ve been tinkering around with Microcontrollers since about February of this year, my main interest is in servo control but also I own more than a couple of 1″ OLED displays, some GPS modules , etc etc. First I started out with the Intel Galileo, but it turned out that it had terrible PWM (they’ve since fixed this with a dedicated PWM chip) and for some reason it would send my servos in to a haywire arrangement that I couldn’t understand. I had a birchwood articulated arm laser cut and shipped to my house, but without being able to resolve the problems with the wild servos I gave up and looked for something with more reliable PWM. I sold it to someone else and bought a Beaglebone black.

This is basically a cell phone with a bunch of pinouts for sensors (like on a cell phone) but also does PWM which is good for servo control, etc. I ran in to issues with the sensors however, they were 3.3v and the Beaglebone only takes, I think, 1.8v max input. This isn’t a difficult problem to solve, but required learning how to split the voltage. In trying this, at 4am, a wayward wire scraped across the BBB and shorted something out. I had to wait almost four months for a replacement. This was shortly after I had finally gotten Debian working on the device and sortd out the CapeMgr, etc that makes servo control in python fairly easy.

In the mean time I ended up ordering an arduino, which I’ve had better luck with. But as it turns out, those servos pull a ton of amperage and they really need to be on their own power circuit to keep from “browning out” the microcontroller, which in retrospect was probably was what was causing the erratic behavior.

In other news, I bought a dedicated PWM controller that talks over I2C, but I did something that caused the motor to overtorque and damage the potentiometer, looks like that servo may become a continuous rotation servo, now.

Posted in computing, Mechanical | Tagged , , , , , , , , | Leave a comment

Converting Bitnami VMDK to Hyper-V VHDX files

I scoured the internet looking for an answer on how to run a Bitnami Virtual Appliance in Microsoft Hyper-V. I’ve had some luck using TurnKey Linux, but the hostnames in TurnKey don’t resolve well (or at all) using windows/OpenWRT so I’ve been looking at Bitnami. Since Windows Pro comes with Hyper-V, I thought I’d give it a try. Unfortunately, while TurnKey provides raw ISOs, Bitnami only provides files (or “stacks” as they call them) that are useful for VMWare and VirtualBox users.

After a couple hours of bouncing around the internet I finally came across a solution – Microsoft Virtual Machine Converter. Except that all of the tutorials referenced mvmc.exe, which is no longer included! It has been recompiled as MvmcCmdlet.dll or some other directly-inaccessible vector and the only exe left is Mvmc.Gui.exe.

Turns out you can call the cmdlet via powershell if you know how to load it. Further googling resulted in this, which I posted to Bitnami’s forums in the hopes of helping out others. I decided to use the Minecraft bukkit bitnami stack as a fun example.

Continue reading

Posted in computing, windows | Tagged , , , , , , , , | Leave a comment

Bicycles and Cats, and why bicycles self-steer themselves (and cats always land on their feet)

I’m curious, how does stem length impact steering feel?

I realize that steering feel is almost 100% impacted by trail (how far the contact patch is behind the line of the head tube) but for example, on my project bike, the old quill stem is 70mm, which puts the handlebars (3 inches) behind the hub; the new quill stem is 150mm which should put it in line with the hub.

I was looking in to wheel trail and came across this experiment again on bicycle stability, but apparently now there’s a Wikipedia page on it, and also a very good video with description of how it works (the wiki page sucks). Basically the idea is to remove things like gyroscopic forces (wheel stability), trail (front wheel auto-stabilization) and see if the bike will keep going in a straight line.

Basically what they decided is that since the front wheel has a non-zero mass, since the fork/wheel is smaller it actually rotates at a faster rate than the rest of the frame. As a result the steering motion causes the bike to self-right despite the fact that it has negative trail.

http://en.wikipedia.org/wiki/Two-mass-skate_bicycle

Ok, so what does that mean exactly? Well fortunately someone as smart as me already went ahead and put this in to a visual frame of reference. With Cats. The internet loves cats. How cats rotate from upside down to right side up in free fall is an interesting part of Physics minutia, but basically the long and short is that once the cat knows what way is up, they pull in their legs in the front and twist, then extend the front legs, retract the rear legs and twist again. Boom, instant reorientation using two sets of angular momentum. That probably made no sense so here’s the video.

Posted in bicycles, Mechanical | Tagged , , , , , , , , , | Leave a comment

NIC Teaming on Windows 8.1 (really)

So there is a way to get NIC Teaming to work in Windows 8.1. WS2012 R2 has dead-easy way to team any two nics (effectively giving you 2 gigabit eithernet if the other end also has at least 2 gigabit capacity). And during the Windows 8 developer preview, Microsoft had forgotten to turn off NIC Teaming, so there are a ton of (outdated) articles explaining how to turn it on. The retail version of Win 8 did not ship with this feature, nor did the retail version of 8.1, not even Pro or Enterprise.

As it turns out, Intel includes NIC Teaming in the PRO version of all their Ethernet cards. Intel pretty much owns the server Ethernet card market so they’re both cheap and plentiful. The driver-level (as opposed to Microsoft’s OS-level NIC Teaming) teaming works between any two Intel PRO Ethernet cards (I think) and, more importantly, works on Windows 7, Windows 8 and Windows 8.1 (and more than likely, someday, Windows 9). For your convenience, Intel makes dual gigabit Ethernet cards for less than fifty bucks which is awfully nice of them. The new version runs about $150, but supports VT-c which is greatly improved for boxes hosting lots of virtual machines, it allows direct hardware pass-through to the VM improving performance and also power consumption/heat.

So how do you get this $50 wonder card to work with Windows 8.1? I’m glad you asked, someone wrote-up this how-to, and that’s what I’m here to share

Continue reading

Posted in computing, windows | Tagged , , , , , , , , , , , | 7 Comments

Intel’s Galileo Ardunio and Powershell

Intel’s Galileo is a pretty neat piece of kit. However it won’t always connect on the same COM port (typically COM3 or COM4). The only way the tutorials tell you to check this is via a menu deep inside the Control Panel if you’re on Windows. The good news is that there’s a pair of simple commands in Powershell that give you access to what you need.

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description

This will give you the device number, description and COM port.

However, the device is half baked. Buggy firmware that won’t take new sketches after 5-10 uploads, lack of even a basic tone() library, and serveo library support so bad it might as well not even be there. Had it for 48 hours and I’m returning it for a Beaglebone Black. On the upside, I got to wander around the house talking about stuff like “pulse width modulation” and feeling smart while I complain about how bad the Galileo is.

As cool as the project is, Intel, you really let me down this time. The board has been out for four months, since October, and there hasn’t been a single firmware or Linux software update. It’s February for crying out loud. Round 2 is with TI and their Beaglebone..

Posted in computing, linux, Mechanical | Tagged , , | Leave a comment