RSS

Monthly Archives: January 2016

Raspberry Pi Model B – Ad-Hoc setup (TL-WN725N)

Hi there,

I have been really busy lately… I’m preparing for my state exam to finish my university studies, which will close a quite big and dark chapter of my life.

In my spare time I’m preparing my Pi for a DIY RC car which will be controlled via WIFI. In order for me to pull this off I need to make connection in Ad-Hoc mode to my Pi. I have a TP-Link nano usb based wifi module (v2). This module for some reason won’t work in this mode with the default hostapd package coming from the official Jessie repositories. So I had to spend some hours digging the net for the proper solution. I was about to abaddon my project and buy a bluetooth dongle when I found this amazing blog.

https://jenssegers.com/43/realtek-rtl8188-based-access-point-on-raspberry-pi

This helped me a lot, so basically I had to follow the steps described in there. I do not want to claim any glory for relaying the knowledge found there. So what I did was the following.

I have removed the already installed package, this switch of dpkg is like an atomic bomb 🙂 it cleans every trace of the package.

dpkg –purge hostapd

Then I entered the following commands in order.

wget https://github.com/jenssegers/RTL8188-hostapd/archive/v2.0.tar.gz
tar -zxvf v2.0.tar.gz
cd RTL8188-hostapd-2.0/hostapd

make
make install

What the above did is simple. It pulled the package of the custom hostapd from github, then extraced it, and compiled the package and installed it into the default path’s.

After this all I had to do is configure the hostapd, and install a DHCP server on my Pi. I have used the dnsmasq as DHCP server, it was fairly simple. So I installed the package with the following command.

apt-get install dnsmasq

Then I configured the two packages. The first one was the hostapd’s config file which is located here: /etc/hostapd/hostapd.conf, by default it contains the following.

# Basic configuration

interface=wlan0
ssid=<your ssid goes here>
channel=1
#bridge=br0

# WPA and WPA2 configuration

macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=<your password goes here>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

# Hardware configuration

driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek

All I had to do is replace the password and ssid lines with my choice. Then I configured the dnsmas package which has a configuratio file here: /etc/dnsmasq.conf, it has many lines by default so I will only pick the ones which are relevant now.

interface=wlan0
dhcp-range=10.0.0.2,10.0.0.200,255.0.0.0,12h

These 2 lines told my software that Pi only likes to server DHCP requests on the wlan0 interface, and the range must be starting from 10.0.0.2 to 10.0.0.200 with an A Class subnetmask, for 12 hours per lease.

Finally I added both services to start at boot time and I was almost ready to go, I had to add a static IP address to my wlan0 interface with the config file: /etc/network/interfaces

auto wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.0.0.0

This is how I made sure the services are starting up at the boot.

update-rc.d hostapd defaults
update-rc.d dnsmasq defaults

Finally I rebooted my Pi and I was able to connect to the network with the specified parameters.

Cheers,
Daniel

 
Leave a comment

Posted by on January 16, 2016 in Uncategorized