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.