Sunday, November 30, 2014

Sunday, November 23, 2014

Friday, November 21, 2014

Thursday, November 20, 2014

Sunday, November 16, 2014

Standalone access point with RPi (ethernet to wifi)

Run raspi-config and run Memory Split and set 16 Mb for GPU.
sudo raspi-config

Make sure your system is up to date
sudo apt-get update && sudo apt-get upgrade -y
Install all pre-requsites
sudo aptitude install rfkill hostapd hostap-utils iw dnsmasq -y
Open network configuration file
sudo nano /etc/network/interfaces
Set static address for wifi. Whole configuration now looks like
auto lo

iface lo inet loopback
iface eth0 inet dhcp

iface wlan0 inet static
address 192.168.29.1
netmask 255.255.255.0
Restart wifi interface
sudo ifdown wlan0
sleep 2
sudo ifup wlan0
Check if wlan0 interface has assigned its new ip address
pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.111  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1470 errors:0 dropped:0 overruns:0 frame:0
          TX packets:879 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1067661 (1.0 MiB)  TX bytes:120858 (118.0 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr c0:4a:00:2b:00:4e
          inet addr:192.168.29.1  Bcast:192.168.29.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Create a new Host Access Point Daemon configuration file
sudo nano /etc/hostapd/hostapd.conf
Paste the content:
ctrl_interface=/var/run/hostapd
macaddr_acl=0 auth_algs=1
driver=nl80211
interface=wlan0
hw_mode=g
ieee80211n=1
channel=7
ssid=pi
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit network name, password and chanel to suit your needs

Erase existing dnsmasq configuration
sudo truncate --size 0 /etc/dnsmasq.conf
Open dnsmasq configuration
sudo nano /etc/dnsmasq.conf
Let the DHCP server assign addreses from 192.168.29.10 to 192.168.29.100
Copy these three lines to dnsmasq.conf. This will be all it is!
domain-needed
interface=wlan0
dhcp-range=192.168.29.10,192.168.29.100,255.255.255.0,12h
Create new startup service
sudo nano /etc/init.d/pipoint
Configure what this service will turn on ip forwarding, enable network address translation and start the access point
#!/bin/sh
# Configure Wifi Access Point.
#
### BEGIN INIT INFO
# Provides: WifiAP
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Should-Start: $network $named slapd autofs ypbind nscd nslcd
# Should-Stop: $network $named slapd autofs ypbind nscd nslcd
# Default-Start: 2
# Default-Stop:
# Short-Description: Wifi Access Point configuration
# Description: Sets forwarding, starts hostap, enables NAT in iptables
### END INIT INFO

# turn on forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# enable NAT (network address translation)
iptables -t nat -A POSTROUTING -j MASQUERADE

# start the access point
hostapd -B /etc/hostapd/hostapd.conf
Set the startup service executable
sudo chmod 755 /etc/init.d/pipoint
Refresh startup cache
sudo update-rc.d pipoint start 99 2
Reboot the device
sudo reboot
Reference:
http://www.pi-point.co.uk/documentation/

Saturday, November 15, 2014

Transfer ethernet DHCP into Wifi Access Point, Raspberry Pi


This tutorial will work if your internet cable already has DHCP. This cable connection will be transfared into wifi connection. So all client who will connect to wifi will use DHCP what your ethernet cable provides.

To do it so:

Update system
sudo apt-get update && sudo apt-get upgrade -y
Install pre-requsites
sudo aptitude install hostapd hostap-utils iw bridge-utils -y
Make sure your wifi can act as an access point
iw list | awk "/Supported interface modes/{f=1} /software interface modes/{f=0;print} f"
This will report somethin like
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
Make sure the AP mode is listed ;)

Set Host Access Point Daemon configuration file to "/etc/hostapd/hostapd.conf"
sudo sed -i "s/^DAEMON_CONF=$/DAEMON_CONF=\/etc\/hostapd\/hostapd.conf/" /etc/init.d/hostapd
Open access point configuration file
sudo nano /etc/hostapd/hostapd.conf
Paste this content
ctrl_interface=/var/run/hostapd
macaddr_acl=0 auth_algs=1
driver=nl80211
interface=wlan0
bridge=br0
hw_mode=g
ieee80211n=1
channel=7
ssid=pi
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit wireless name, password and chanel to suit your needs

Now open network configuration and make sure the bridge settings is there
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

auto br0
iface br0 inet static
address 192.168.0.113
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
bridge-ports eth0 wlan0
Reboot you pi and check for wifi network.

Trobleshooting:
IP adress of bridge network (br0) are diferent from ethernet (eth0).
pi@raspberrypi ~ $ ifconfig
br0       Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.113  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fe8c:7550/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7877 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3491 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:959834 (937.3 KiB)  TX bytes:587858 (574.0 KiB)

eth0      Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.111  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8416 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3493 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1132541 (1.0 MiB)  TX bytes:617090 (602.6 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr c0:4a:00:2b:00:4e
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Also here is my own image. This should work on 192.168.0.X network out of the box
https://googledrive.com/host/0B_esWdErYKaLQkZuM0VXRUNyVEk/2014-11-15-wheezy-raspbian-eth0-wifi0-bridge-192-168-0-0.7z
d4fb01f3d87d5fead4f614795e194766
8e9dea973ecc31364ee12b1e2f437b1cc346f8f4

Friday, November 14, 2014

How to clone wheezy raspbian

List the current image size. Use ls -l
-rwxrwxrwx    1 root     root     3276800000 Sep  9 07:42 2014-09-09-wheezy-raspbian.img
Now take this 3276800000 devide by 1048576 and you got 3125

Now you can clone with dd
dd if=/dev/mmcblk0 of=/dev/sda1/custom-image.img bs=1M count=3125
Magic number is 1048576 :)

How not to do, fourth edition

Task is to re-create user profile on Windows 7 operating system.

So here is the steps i do:
Log out the current user who is somehow pretty buggy.
Log in with user who has administrator rights.
Go to c:\users\
Rename Andy to Andy.old
Log out the administrator
Log again with Andy. Everything is fresh and clean :)
Move all documents from Andy.old to Andy
Everything is working, continue living :)
.. but NOT in long terms!
One day after windows update the new Andy can be gone.

And again this is not how to do things!

Read also first, second and third edition of "How not to do"

You have been logged on with a temporary profile


To solve this issue you have to log on to system with user who have administrator rights.
Now go to c:\users\ and backup all neccessary profiles to directory which is NOT c:\users\

Open System Properties navigate to Advanced tab and remove all profiles in the way it should be done

Now open Windows Explorer and check if all looks fresh and clean under c:\users\
If something looks not OK then remove this acounts which you really recognize as unwanted. Also delete c:\users\TEMP direcotry.
Sometimes some accounts can not be removed completely. In this case you need restart computer.

Open regedit and navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
Check one by one and delete all keys (at left panel) which by looking at ProfileImagePath (at right panel) you recognize as unwanted now

Now reboot system and be happy :)

Sunday, November 9, 2014

Wednesday, November 5, 2014

Array in linux shell without creating file

array=$(ls -1; echo "end of file";)
printf %s "$array" | while IFS= read -r line
do {
echo $line
} done
Another way using sed
array=$(ls -1 | sed '$aend of file')
printf %s "$array" | while IFS= read -r line
do {
echo $line
} done

Sunday, November 2, 2014

Blog Archive