Share internet Soft-AP hostapd via NAT

Follow up on my earlier blog Run your wifi-dongle as Access Point (Soft-AP) 8188eu on Linux, about using your Wifi dongle as a Wireless Access Point.

We got the WIFI AP started. Next step is to share the Internet connection on the box (enabled via ethernet cable – interface eth0)
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
To set this up automatically on boot, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:
net.ipv4.ip_forward=1

Enable NAT in the kernel & rules to use ethernet interface via wifi interface.

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlx00e04c0876f5 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlx00e04c0876f5 -o eth0 -j ACCEPT

Finally persist the iptables configuration and restore it on reboot.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:
up iptables-restore < /etc/iptables.ipv4.nat

and….!
sudo reboot

That’s all folks!

 

VPN

Similarly, if you have a VPN running on the box. And you want to expose the VPN connection via the Wireless Access Point:

(replace eth0 by tun0 in the iptables above)

Test

curl --interface tun0 freegeoip.net/json/

Or just hit the url freegeoip.net/json/ on your browser.

Source: http://elinux.org/RPI-Wireless-Hotspot

Create local streaming server on Linux 

I have got this cool raspberry pi 2 setup which is hooked to my TV as a Media Center (osmc/kodi) and have got SickRage and CouchPotato installed to fetch my subscribed shows from the internet. Which later OSMC picks up and indexes with all meta and subs. 

openvpn creates a VPN tunnel for all outgoing connections. So I can still use my mobile to ssh to and as a remote for the media center (Yatse). 

Yatse doesn’t let me play videos I have on Rpi on my Phone (even when I am on the same network) under the free app.

So I resorted to dlna/upnp. One option was to switch on dlna /upnp on Kodi/osmc but that would have listed so much data. I wanted more control on what files to expose. So, I started a dlna server on rpi and accessed via VLC on my phone. 

Here’s how!! 

$ sudo apt-get install minidlna

$ sudo vi /etc/minidlna.conf
inotify=yes

media_dir=/path/to/folder
 $ sudo service minidlna force-reload

 $ sudo service minidlna restart

VLC automatically detects the server running on the same network. 

All good! Seeking works great too. 

Add 1600×900 (16:9) resolution to Ubuntu


$ xrandr

# look at the name of your device
# eDP1 connected primary 1440x900+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
# HDMI1 disconnected (normal left inverted right x axis y axis)
# VGA1 disconnected (normal left inverted right x axis y axis)
# VIRTUAL1 disconnected (normal left inverted right x axis y axis)

$ xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
$ xrandr --addmode eDP1 "1600x900_60.00"
$ xrandr --output eDP1 --mode "1600x900_60.00"

display_1600_900

source: http://ubuntuforums.org/showthread.php?t=1966900

update: Add it to your dm startup script

Find out what’s your default dm:

$ cat /etc/X11/default-display-manager

Eg. try adding pre-start or post-start scripts to /etc/init/lightdm.conf

How to install deluge bit-torrent client on OSMC Raspberry Pi

My RPi runs OSMC with SickRage, CouchPotato and Transmission-daemon.

I have been using transmission-daemon for sometime and it works great. Recently I had some I/O trouble with a big torrent and decided to install another BitTorrent client on the box – just in case.
I tried to look around but couldn’t get any other known torrent clients installed on the ARM box (absence of the binaries you can say). There are ways to get x86 utorrent binary installed on RPi but I didn’t want to go that far.

 


#Install the required packages

sudo apt-get install deluged deluge-web

#Set your auth credentials

sudo echo "osmc:osmc:10" &gt;&gt; /var/lib/deluged/config/auth

#Change various settings, seed-ratio; download directory etc

sudo vi /var/lib/deluged/config/core.conf

#restart the service to take effect

sudo service deluged restart

#check out if the service started OK

stty cols 2000

sudo service deluged status -l

#Create the web ui service

sudo vi /etc/systemd/system/deluge-web.service

[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target

[Service]
Type=simple

User=osmc
Group=osmc
UMask=027

ExecStart=/usr/bin/deluge-web

Restart=on-failure

[Install]
WantedBy=multi-user.target

#Set the service to start upon system startup

sudo systemctl enable deluge-web.service

#Now start the service for the first time.

sudo service deluge-web restart

sudo systemctl start deluge-web

#Go to URL

http://<<RPi URL>>:8112/

#Enter the default password:

“deluge”

#Set a new password.

#Connection Manager:

Add:

localhost

58846

osmc

osmc

That’s all folks!

git: sparsecheckout: Partially pull a repo

So I got this Firefox Device (called Intex Cloud Fx) a couple of weeks back but still couldn’t switch to it (the cold turkey way) as the keyboard application is still in its infancy and I can barely type on QWERTY anymore (long sentence?)!

I decided to dive right into it. I spent my weekend trying to understand the OS better and managed to push some test applications to the device (and they worked! And I could even debug them from my browser! Cool stuff!).

The end game (more like the next goal) is to get/create a keyboard app which has the placement of keys that my mind would understand. (Think: Colemak)

To do that, I started looking around for examples and that’s when I found something and forked it immediately 🙂  test-keyboard-app

To pull that repository on my laptop was truly intimidating (it’s a full blown Operating System after all). That’s when I found out what magic git sparsecheckout could do.


$ git init repo

$ cd repo/

$ git remote add -f origin https://github.com/nikunjlahoti/gaia.git

# Updating origin
# remote: Counting objects: 356086, done.
# remote: Compressing objects: 100% (105268/105268), done.
# remote: Total 356086 (delta 245156), reused 356086 (delta 245156)
# Receiving objects: 100% (356086/356086), 817.56 MiB | 892.00 KiB/s, done.
# Resolving deltas: 100% (245156/245156), done.

$ git config core.sparsecheckout true
# Specifying the intention now

$ echo "dev_apps/test-keyboard-app/" >> .git/info/sparse-checkout
# list of directories to be included

$ git pull origin master
# From https://github.com/nikunjlahoti/gaia
# * branch master -> FETCH_HEAD

$ ls -a
dev_apps .git

# voila

#NoteToSelf #LetTheFunBegin

Switch to Colemak/Dvorak

Its true! I can touch type without even looking at the monitor, with an average WPM of 60+ (most people can! Are you most people?), but then sometimes LOVE is not enough.

 

#1 Why?

QWERTY wasn’t designed with the user in mind (typewriter wins). More info: here & here

User productivity increases. Less fatigue – don’t have to worry about http://en.wikipedia.org/wiki/Repetitive_strain_injury

Colemak etc are less prone to typos.

& for the sheer thrill in doing something new & rare (btw eight years ago I moved to Linux. No analogy! *Wink*)

 

#2 How?

Ideally all you need is an OS that understands the layout. All modern operating systems do.

That’s how you can switch layouts in Windows Ubuntu etc (just google).

 

Optionally, if you are like me – feedback is vital.

  • Let’s buy that keyboard?
  • Maybe those glowing stickers?
  • Ah! Just get me a screw driver X(

Pop the keys out and rearrange!

image

The red “i” has landed on the home row. Good stuff. Please don’t do that to your laptop. USB keyboard is pretty easy to acquire.

Downside: F & J have moved (if you know what I mean). #anchor #bump #ridges

 

#3 Next Steps

Learn

 

Q. All said and done – Why is QWERTY still in production?

A. I don’t have to answer that as we all know what will happen if you go to your manager/boss and ask him to sponsor this migration. For him all that’s expected out of you is that you ‘deliver’ – which you are already capable of.

 

Happy hacking!

 

PS: WPM has significantly gone down. But do not worry. #FreshStart

PPS: Yes! I used Colemak to write this post.

more stuff:

http://en.wikipedia.org/wiki/Latin-script_non-QWERTY_keyboards

 

Update (20130812):

Q. How to Switch in Android?

A. Google Keyboard is the answer. Get the app.

Settings — Language & Input — Google Keyboard — Advanced settings — Custom Input Styles — Add style (Currently it supports 6 layouts)

This is definitely cool. Gesture typing is fun.

Android-Colemak

Android-Colemak