Tuesday, November 19, 2013

Raspberry Pi system (Raspbian) size optimization

You use Raspbian system image but only need RPi as a special purpose server so many packages are unnecessary (especially GUI components). A few suggestions how to slim down the Raspbian (or any other Debian based RPi distribution) are explained here:
https://extremeshok.com/2012/07/22/raspberry-pi-raspbian-tuning-optimising-optimizing-for-reduced-memory-usage/
https://wiki.debian.org/ReduceDebian

There are at least two benefits from slimmed down system:
- You can re-use old SD cards lying around the house and
- the package management (apt-*, dpkg) work faster as there are less files to process.

Sunday, February 24, 2013

Adding a track to google maps

So you have your own web page that displays a map from Google Maps and you want it to show a GPS track. Well, it does not work out of the box as Google Maps API does not support loading tracks by itself. But luckily a simple solution in a few lines of jQuery code exists that does exactly that - loads a GPX track onto a map. The code and everything else is accessible at: http://www.jacquet80.eu/blog/post/2011/02/Display-GPX-tracks-using-Google-Maps-API

Monday, December 3, 2012

Mikrotirk L2TP/IPSec configuration (Windows compatible)

/ppp profile
add change-tcp-mss=yes dns-server=192.168.1.254 local-address=172.21.16.254 \
    name=VPN-server only-one=no remote-address=VPN-server use-compression=\
    default use-encryption=default use-ipv6=no use-mpls=default \
    use-vj-compression=default wins-server=192.168.1.3
set 3 change-tcp-mss=yes name=default-encryption only-one=default \
    use-compression=default use-encryption=required use-ipv6=no use-mpls=\
    default use-vj-compression=default

/ppp secret
add caller-id="" disabled=no limit-bytes-in=0 limit-bytes-out=0 name=user password=passwd \
    profile=VPN-server routes="" service=l2tp

/ip pool
add name=VPN-server ranges=172.21.16.100-172.21.16.200

/interface l2tp-server server
set authentication=mschap1,mschap2 default-profile=VPN-server enabled=yes \
    max-mru=1460 max-mtu=1460 mrru=disabled

/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha1 disabled=no enc-algorithms=3des \
    lifetime=30m name=default pfs-group=modp1024

/ip ipsec peer
add address=0.0.0.0/0 auth-method=pre-shared-key comment="COMPANY VPN" \
    dh-group=modp1024 disabled=no dpd-interval=2m dpd-maximum-failures=5 \
    enc-algorithm=3des exchange-mode=main-l2tp generate-policy=yes \
    hash-algorithm=sha1 lifetime=1d my-id-user-fqdn="" nat-traversal=yes port=\
    500 secret=secret_password send-initial-contact=yes

/ip firewall filter
add action=accept chain=input comment="L2TP VPN" disabled=no dst-address=\
    xx.xx.xx.xx dst-port=500,4500,1701 protocol=udp
add action=accept chain=input comment="L2TP VPN" disabled=no protocol=ipsec-esp
add action=accept chain=output comment="L2TP VPN" disabled=no dst-address=\
    xx.xx.xx.xx dst-port=500,4500,1701 protocol=udp

/system logging
add action=memory disabled=no prefix="" topics=ipsec
add action=memory disabled=no prefix="" topics=radius

Source: http://forum.mikrotik.com/viewtopic.php?f=2&t=65059

Tuesday, November 27, 2012

Serving a custom catch-all web page on a private WiFi

Sometimes you would like to publish a specific private web page for your WiFi users. For example, you want to allow the guests in your restaurant to access the on-line version of your menu while using your open WiFi hotspot (and no other internet web page!). It is an easy task with an OpenWRT or DD-WRT router (your web pages still need to be served from a server, not the router itself). This might be known with the keywords catch-all, wildcard, HTTP, DNS.

First we need to make sure we catch all DNS requests and return the IP of our web server for all different domains. The trick is in an additional DNSMasq configuration option (192.168.1.5 is your web server):
address=/#/192.168.1.5
Of course, your DHCP server should give only your DNS as the DNS server to the client. And this is all we need if the router is not connected to internet as any other hacking (e.g. entering a custom DNS server on the client or trying to use a VPN) will have no effect. But you may still enable the HTTP redirect in DD-WRT firmware just to be sure to catch the IP only web requests also.

When all domains are redirected to our IP address we need to instruct the web server to serve the same page for all requests (ignoring the Host header) which is pretty easy and the most common default configuration. But for visual effect you can server your page on myrestaurant.com (it doesn't matter if the domain exists or not as long as you use it only inside your internal network) and force a http redirect to it if a guest is trying to access any other domain (e.g. facebook.com or google.com). A hint for Apache users (others should google for "http redirect 301" and your web server name):
Redirect 301 / http://www.newdomain.com/

Of course it is highly recommended not to use this wireless network for anything else as it will look bogus from users perspective (web pages not loading etc.). Use a firewall or do not connect the router to internet at all.

Resources for DNSMasq configuration:

http://serverfault.com/questions/351108/using-dnsmasq-to-resolve-all-hosts-to-the-same-address
http://www.dd-wrt.com/wiki/index.php/DNSMasq_-_DNS_for_your_local_network_-_HOWTO
http://coolaj86.info/articles/redirect-domains-and-dns-using-dd-wrt.html

WARNING: this guide is not yet tested but in theory it should work. This warning will be removed when I actually test it (or get a confirmation that it works).

Monday, October 1, 2012

AirCam power usage

Specifications for:
AirCam is 2.4 Watts Maximum.
Actual Measurement:
12.06 Volts x 0.157 Amps = 1.89342 Watts 
Ambient Temperature 19.3 Degrees Celsius and a cable length of 2 metres.

Specifications for:
AirCam Dome is 3.5 Watts Maximum.
Actual Measurement:
12.06 Volts x 0.151 Amps = 1.8821 Watts 
Ambient Temperature 19.5 Degrees Celsius and a cable length of 2 metres.

Source: http://forum.ubnt.com/showthread.php?p=326727

Thursday, August 30, 2012

Fog photography

A nice tutorial on fog photography, how to make the best of it. Not avoiding or removing it but taking it as an advantage. http://www.cambridgeincolour.com/tutorials/fog-photography.htm