zaterdag 25 mei 2013

Android lockscreen

Custom android lockscreen without cropping or extra app

Recently i wanted to change my android lockscreen for my SGS2, and had some trouble doing so.

There are different apps on the android market for this but i do not want to install an app for it because i have apps enough allready.

Here i will describe a way to set you lock screen so your selected image is allways full screen, without the need for any extra application. Its very simple, but i didn't find it anywhere on the internets to do it this way so i thought i'd write it up real quick.


Because android allways shows the cropping option for the selected image, even though the image resolution is the same as your screen resolution, leaving you with a background showing only half the image, with no way to zoom or expand the canvas.


Its very simple really. For my SGS2, my screen resolution is 480x800. So to workaround the bug, just create a new image in any image editing program of your choise with DOUBLE the width resolution, for the SGS2 that would be 960x800. Paste your image in the middle and save.

It should look something like this:



Then re-upload it to your phone, and set it again as lockscreen, the image should now appear in the selected box 100%, and the rest is cropped.


FYI: if you cant find how to set a lockscreen, just open the image gallery, browse to the picture you want to set. Then in options -> Set As... -> Lock Screen

vrijdag 19 april 2013

OpenVPN Server on Raspberry Pi

Here i will explain how to quickly install OpenVPN on a Raspberry Pi running raspian

Needed Files:
Get Raspian Wheezy HERE
To get it installed on your SD card you need Win32DiskImager (Download it HERE)

After installing the image boot up your Pi, finish the setup by following instructions on the screen. Open up a command line tool if you booted to X.

First download the needed software packets:
apt-get install openvpn openssl module-init-tools zip dos2unix

Then, enable the tun module:
 modprobe tun

Load the tun module on boot:
echo '# Needed by OpenVPN
tun' >> '/etc/modules'

Create device file:
mkdir --parent '/dev/net'
mknod '/dev/net/tun' c 10 200

Install OpenVPN Tools:
wget 'https://raw.github.com/biapy/howto.biapy.com/master/openvpn/openvpn-tools' \
    --quiet --no-check-certificate --output-document='/usr/bin/openvpn-tools'
chmod +x '/usr/bin/openvpn-tools'

Get the 'update-resolve-conf' script:
wget 'https://raw.github.com/biapy/howto.biapy.com/master/openvpn/update-resolv-conf' \
  --quiet --no-check-certificate --output-document='/etc/openvpn/update-resolv-conf'
chmod +x '/etc/openvpn/update-resolv-conf'

Set SSL Certificate defaults:

openvpn-tools initialize

Setup Logs:
echo "/var/log/openvpn/*/*.log {
  daily
  missingok
  rotate 10
  compress
  delaycompress
  notifempty
  create 600 root root
  postrotate
    /etc/init.d/openvpn restart > /dev/null
  endscript
}" > "/etc/logrotate.d/openvpn"

Create server:
openvpn-tools create-server local-domain.vpn vpn.domain.com

Where:

local-domain.vpn is the VPN name of the new server.
vpn.domain.com is the Internet host name of the VPN server.
Default port is 1194 UDP. If needed, you can change ports later in the config file.

Next, create client configuration and certificates, they will be stored in: " /etc/openvpn/config/local-domain.vpn/clients/Client-name"
openvpn-tools add-client local-domain.vpn client-alias

This will create configuration files and certificates in a zip file. You can retrieve them with PSCP if you do not want to setup an ftp server.

Enable/Disable NAT:
openvpn-tools toggle-nat local-domain.vpn

Toggle Forced use of tunnel for all network traffic on clients:
openvpn-tools toggle-gateway local-domain.vpn

That should to the trick. Setup your client with clientsoftware from the OpenVPN website and copy the contents of the zip file downloaded from the pi into the config folder. U should now be able to use the VPN tunnel succesfully. Be sure to keep in mind to configure port forwarding on your router if needed. If you provider blocks port 1194, you can change that in the config file located at '/etc/openvpn/local-domain.vpn.conf' and allso the client config file!

For safety, allso create a new user with sudo rights and remove user pi.

maandag 25 februari 2013

Quick Start Vyatta OpenVPN Client/Server setup.

Quick Start Vyatta OpenVPN Client/Server setup (Belgium (ISP:Belgacom) with self signed certificates)


In this article i will explain how to setup a VPN server in your home using OpenVPN using Vyatta as a vpn server. The primary router in this setup is a sagem BBOX2 from ISP Belgacom. Router setup changes that have to be made will allso be covered in this guide.

THIS video allso explains from start to end on how to do this, but its pretty long(1h 13m). with this guide you should be able to set this up faster. If your having trouble following the instructions given below i advise you to watch the video anyways and follow it step by step. (exept for the download links use the ones provided below)

We will use the LAN network of 192.168.1.0/24 and VPN net 192.168.100.0/27.

Router IP: 192.168.1.1/24
VPN Server IP(Vyatta): 192.168.1.100
WAN IP/Hostname: I use a DynDNS account for dynamic wan ip updating, but there are other alternatives

Prerequisites:
Vyatta: http://www.vyatta.org/downloads
OpenVPN Client: http://openvpn.net/index.php/download.html (Bottom of page: Community Downloads)

If you do not have dedicated hardware to install the Vyatta iso you can use a virtualization packet of your choise to do this.

Burn or mount Vyatta and boot from the iso.

log in with the standard passwords:
user: Vyatta
Password: Vyatta

or

user:root
Password: Vyatta


To install the system to hard drive, enter the "install-system" command. After install, unmount and reboot.
after login, change the password using the "sudo passwd" command.

First, set your ip adress so you Vyatta router is reachable

Enter config mode:

root@vyatta:~# configure
[edit]
root@vyatta# set interfaces ethernet eth1 address 192.168.1.100/24 
root@vyatta# commit

root@vyatta# saveSaving configuration to '/config/config.boot'...Done[edit]root@vyatta#


The commit is needed in vyatta to actually apply the given command(s),  otherwise your commands will not be written to config. Additionally you need to save the running configuration so that it is preserved after reboot. In this guide i have cut the commit and save commands to save space.

Then setup the VPN interface:
Here i use port 443, whereas the standard port for openVPN is 1194. Most ISP block this port, so the use of port 443 is allso supported by openVPN. For Belgacom ports 80 and 443 can be opened, This is not enabled automaticly though, you have to log in to your E-Services account and configure there to have the ports opened)

root@vyatta# set interfaces openvpn vtun0 local-port 443 
root@vyatta# set interfaces openvpn vtun0 protocol udp 
root@vyatta# set interfaces openvpn vtun0 mode server 
root@vyatta# set interfaces openvpn vtun0 openvpn-option "--mssfix --tun-mtu 1488" 
root@vyatta# set interfaces openvpn vtun0 replace-default-route 
root@vyatta# set interfaces openvpn vtun0 server subnet 192.168.100.0/27

Then create and sign your certificates, watch Roggy's video from 32:30 on how to do this.
Set certificate info:

root@vyatta# set interfaces openvpn vtun0 tls ca-cert-file /etc/openvpn/ca.crt 
root@vyatta# set interfaces openvpn vtun0 tls cert-file /etc/openvpn/vpn1.crt 
root@vyatta# set interfaces openvpn vtun0 tls dh-file /etc/openvpn/dh1024.pem 
root@vyatta# set interfaces openvpn vtun0 tls key-file /etc/openvpn/vpn1.key

Set up NATting for the VPN net:
root@vyatta# set nat source rule 10 outbound-interface eth1
root@vyatta# set nat source rule 10 source address 192.168.100.0/27
root@vyatta# set nat source rule 10 translation address masquerade

Set next hop:

root@vyatta# set protocols static route 0.0.0.0/0 next-hop 192.168.1.1


Enable SSH access(to upload/download cert files)
root@vyatta# set service ssh port 22

Your config should look like this:

interfaces {
    ethernet eth1 {
        address 192.168.1.100/24
        duplex auto
        hw-id 9a:6f:ae:18:cd:bf
        smp_affinity auto
        speed auto
    }


    openvpn vtun0 {
        local-port 443
        mode server
        openvpn-option "--mssfix --tun-mtu 1488"
        protocol udp
        replace-default-route {
        }
        server {
            subnet 192.168.100.0/27
        }
        tls {
            ca-cert-file /etc/openvpn/ca.crt
            cert-file /etc/openvpn/vpn1.crt
            dh-file /etc/openvpn/dh1024.pem
            key-file /etc/openvpn/vpn1.key
        }
    }
}
nat {
    source {
        rule 10 {
            outbound-interface eth1
            source {
                address 192.168.100.0/27
            }
            translation {
                address masquerade
            }
        }
    }
}
protocols {
    static {
        route 0.0.0.0/0 {
            next-hop 192.168.1.1 {
            }
        }
    }
}
service {
    ssh {
        allow-root
        port 22
    }
}

Next, configure you BBOX2:
Log in to your BBOX through your webbrowser (usually ip 192.168.1.1)

Then Advanced Settings -> LAN Servers:

Add port forwarding for port 443 and point it to your vyatta router interface (192.168.1.100)


Disable your router's firewall, or if you dont want to do that add a port trigger rule and afvanced filteringrule for port 443. 


Next, you need to change your WAN MTU because on the autodetect function your VPN connection will fail!! The standard MTU value is 1500, but this wil generate errors, so we will set it to match the BBOX maximums MTU of 1488. If you have another ISP, you can just try with the standard settings first.


Set the MTU value to 1488. 



Next, setup your OpenVPN client. After installation go the C:\Program Files\OpenVPN\config\ folder and place there your certificate-, key and dh file. Next go to your network inferfaces and rename the "TAP-Windows Adapter V9"'s name to Tap0. Now open the client.ovpn and change the following value's

change following parameters to:
#TAP Adapter name
dev-node Tap0

#protocol
proto udp

#server hostname/ip
remote "YOUR WAN IP" 443

#SSL/TLS params:
ca ca.crt
cert ***.crt
key ***.key

comment out comp-lzo

Add the folowing parameters:
--tun-mtu 1488
--mssfix
--script-security 2

Save the config and now you can start the openVPN client software. It is very important to run it with administrator rights because changing the routing for the VPN tunnel required admin rights.


Now you should be ready to use your VPN tunnel. If i should have forgotten any steps just mention it the comments and i will add it later on. I typed this up rather quick and my network setup is different then the one displayed here, but wanted to make a guide that showed a working config for this ISP. I hope this helps you setup a VPN tunnel quickly.

If you have any configuring just leave a comment and i will try to help.