I am using the Raspberry Pi Model 2 B with 1 GB RAM with the EDIMAX nano USB Adapter. At first I was using NOOBS on the Rapsberry Pi and wanted to set up an ad-hoc network between two such Pi's.
I tried configuring one of the RPi with the same configurations as mentioned below:
#etc/network/interfaces for pi-1
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.50.1
netmask 255.255.255.0
wireless-channel 12
wireless-essid pi-adhoc
wireless-mode ad-hoc
#etc/network/interfaces for pi-2
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.50.2
netmask 255.255.255.0
wireless-channel 12
wireless-essid pi-adhoc
wireless-mode ad-hoc
I have set Pi-1 as a DHCP server (using the ISC-DHCP-Server Daemon) so that I can SSH into the Ad-hoc network to the Pi's for ease of accessibility through my Laptop. The DHCP Server configurations are as follows:
ddns-update-style interim;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
option subnet-mask 255.255.255.0;
option domain-name "pi-adhoc";
subnet 192.168.50.0 netmask 255.255.255.0 {
range 192.168.50.3 192.168.50.150;
}
and then run the daemon pi-1 ~$ sudo service isc-dhcp-server start
I also force the Pi's to join the ad-hoc network by configuring the rc.local files on both of them as follows:
#! /bin/bash
# For Pi-1 /etc/rc.local
adhocNetwork(){
echo "connecting to ad hoc network"
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid pi-adhoc
iwconfig wlan0 channel 12
ifconfig wlan0 192.168.50.1 netmask 255.255.255.0 up
echo "connected to ad hoc network"
}
adhocNetwork
exit 0
#! /bin/bash
# For Pi-2 /etc/rc.local
adhocNetwork(){
echo "connecting to ad hoc network"
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid pi-adhoc
iwconfig wlan0 channel 1
ifconfig wlan0 192.168.50.2 netmask 255.255.255.0 up
echo "connected to ad hoc network"
}
adhocNetwork
exit 0
When I use my WiFi on my Laptop and connect to the pi-adhoc network created by the Pi's I get an IP address from the DHCP Server from the pool from Pi-1 and can ssh into the Pi-1 and just to check connectivity I can Ping the laptop from RPi to Laptop and vice versa.
When I try to Ping Pi-2 from Pi-1, it is unreachable and vice versa. But I can connect to the Pi-2 from the Laptop and vice versa.
Scenario: PI-1 <---> Laptop and PI-2 <---> Laptop but NO connectivity from PI-1 <--/--> PI-2 I cannot connect the Pis together.
I also upgraded the NOOBS to Wheezy using the following: sudo apt-get update sudo apt-get dist-upgrade
But the Problem still Exists.
Any help would be appreciated. Thanks.
So finally the connectivity issue has been resolved provided if one does not use the Edimax EW7811UN Wireless Dongle. The problem is related to a driver which is not supported for Linux Kernels past 3.9 versions. The driver specifically is called 802nl11 driver.
An alternate solution which solves the connectivity is using WiFi dongles which have the Ralink RTL5370 drivers in them. I am currently using LogiLink WL0145 Wireless N USB Adapter.
A good check for drivers can be done using lsusb
command when the USB dongle is connected to the RPi. Now with the same configurations I can ping both the Raspberry Pis.
There has been a driver compatibility issue with the Model B+ for Raspberry Pis when using Edimax Dongles particularly in Ad-Hoc Mode. Hence it is advisable to switch to other WiFi Dongles when using RPis in Ad-Hoc mode particularly ones with Ralink Technology RT5370 Wireless Adapters.
There is still no support for Edimax 7811UN for Ad Hoc mode for Jessie and Jessie Lite 8.0