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

Run your wifi-dongle as Access Point (Soft-AP) 8188eu on Linux

I have got the Soft AP to work in Windows (using the supplied CD) and Linux by following these steps. I was able to connect/get dhcp ip from my Android.

Will update this post with //TODO

1) internet sharing with ethernet or built in wifi interface

2) Start openvpn tunnel and essentially this Access Point will be VPN protected

(think: Netflix; after connecting my Chromecast and Android to this mountpoint)

3) do this on my Raspberry Pi 2 so that my Laptop can get some sleep 🙂

Prerequisite (LOL! Not really! haha):

$ sudo apt install snapd

$ sudo snap install plexmediaserver

$ sudo apt-get install git

$ sudo apt-get install build-essential

$ sudo apt-get install rbp2-headers-$(uname -r)

A. Get the latest driver. Blacklist the staging one

sudo lshw -C network

will show your driver as r8188eu

modinfo r8188eu

is in staging directory.

1.

git clone https://github.com/lwfinger/rtl8188eu

make all

sudo make install

2.

sudo vi /etc/modprobe.d/50-blacklist-8188eu.conf

blacklist r8188eu

3.

sudo reboot

lsmod | grep 8188

should show you ‘8188eu’

sudo lshw -C networkwill still show r8188eu – but that’s OK.

B. Find the wifi interface name

ifconfig

wlx00e04c0876f5 Link encap:Ethernet  HWaddr 

C. Remove existing hostapd and install the patched version

1.

sudo apt-get autoremove hostapd

2.
git clone https://github.com/jenssegers/RTL8188-hostapd

3.

cd RTL8188-hostapd/hostapd

sudo make

sudo make install

4. (Optionally)

cd RTL8188-hostapd/wpa_supplicant

sudo make

sudo make install

5.

sudo vi /etc/hostapd/hostapd.conf

# Basic configuration

interface=wlx00e04c0876f5

ssid=AntMan

channel=6

#bridge=br0

# WPA and WPA2 configuration

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=3

wpa_passphrase=ChangePassPhrase

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

# Hardware configuration

driver=rtl871xdrv

ieee80211n=1

hw_mode=g

device_name=RTL8188EU

manufacturer=Realtek

6.

sudo vi /etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

D. Adding dhcp capabilities

1.

sudo apt-get install udhcpd

2.

sudo vi /etc/udhcpd.conf

start           192.168.42.2    #default: 192.168.0.20

end             192.168.42.24   #default: 192.168.0.254

interface       wlx00e04c0876f5         #default: eth0

remaining       yes             #default: yes

opt     dns     8.8.8.8 8.8.4.4

option  subnet  255.255.255.0

opt     router  192.168.42.1

option  lease   864000          # 10 days of seconds

3.

sudo vi /etc/default/udhcpd

#DHCPD_ENABLED="no"

E. Setting up the wifi router on static ip and hooking udhcpd start

sudo vi /etc/network/interfaces

auto lo

iface lo inet loopback

auto wlx00e04c0876f5

iface wlx00e04c0876f5 inet static

        address 192.168.42.1

        netmask 255.255.255.0

post-up service udhcpd start

F. Finally restart the services and reboot. You will see Access Point ‘AntMan‘ upon reboot.

sudo service hostapd start

sudo update-rc.d hostapd defaults

sudo reboot

Happy hacking!

Source: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=54946

Wifi Dongle: http://www.snapdeal.com/product/leoxsys-150-mbps-nano-wifi/1179610 

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!