11

How to configure RPi 3 ad-hoc mode? I can't configure my RPi 3, i have seen tutorials but everything is about RPi 2 and the wireless usb but the RPi 3 has that module integrated, so i can't continue with my project, i'm trying to do it from the terminal in raspbian jessie (normal, not light version), so, if someone knows how to set up the RPi 3 in Ad-Hoc mode i will bless you.

Tutorials are from internet and books, but i can't find how to configure exactly in RPi 3, i'm getting a little nervous, so please, help me if you know the answer!!

Alejandro Elvira
  • 111
  • 1
  • 1
  • 3

2 Answers2

12

This answer is still valid, but is not best practice in Stretch. See How to set up networking/WiFi You can use dhcpcd but prevent dhcpcd from configuring the wlan0 interface.

I have setup Ad-Hoc mode on my Pi3.

This involves modification to network configuration file /etc/network/interfaces so you should first make a backup e.g. sudo cp /etc/network/interfaces /etc/network/interfaces.orig.

Replace the interfaces file with the following:-

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
  address 10.2.1.1
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid PiAdHocNetwork
  wireless-mode ad-hoc

You can choose your own address, SSID and wireless-channel, but all machines should have the same settings.

Strictly you should should disable dhcpcd as this will try to automatically configure networks. sudo systemctl stop dhcpcd.service will stop (deactivate) dhcpcd.

If /etc/network/interfaces calls dhcp it will automatically be disabled.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • +Milliways have you tried & succeed to run ad hoc mode with WPA2 encryption ? – user48235 Jun 19 '16 at 05:11
  • @dun32 It is not possible. AFAIK `ad-hoc` only provides basic security. I have not implemented any security, as I only use in isolated circumstances where no alternative is possible. – Milliways Jun 19 '16 at 10:12
  • @Milliways I tried your answer and both of my PIs says their `wlan0` is up. However, they don't have the same the ip address I entered in the interfaces file and I can't seem to get them to talk to each other. For instance, I tried to PING one PI from another. I basically have two PIs. – ThN Mar 30 '17 at 18:59
  • @Milliways, is it possible to connect multiple (more than 2) raspberry pi-s to the same ad-hoc network? – Tugay Mar 03 '22 at 21:33
5

Ad-Hoc Network / Access Point / Bridge Connection

You want to wireless connect to the pi but there are no available wireless networks. Create your own!

The Raspberry Pi can be set up to broadcast a wireless network. This network allows you to connect the the pi, but will not connect to the internet.

You may also use the Raspberry Pi as an access point and share an internet connection (bridge)

Follow this tutorial (no ethernet bridge, I have used this successfully) http://www.raspberryconnect.com/network/item/331-raspberry-pi-auto-wifi-hotspot-switch-no-internet-routing

hostname -I 

Run this on Pi, Then I connected from to the second IP address listed via

ssh pi@[ipaddr] 

from my Ubuntu host machine.

With ethernet bridge (I have not tested this, but from the same tinkerers as ↑) http://www.raspberryconnect.com/network/item/330-raspberry-pi-auto-wifi-hotspot-switch-internet

Ian Zurutuza
  • 399
  • 1
  • 4
  • 10