1

There's plenty out there on setting up an ad-hoc network on your RPi, (Mine's an A, I believe.) but almost none on how to do it when you're using Raspbian Jessie. As such, I'm having a bit of trouble getting things working.

I've altered my /etc/network/interfaces to read

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
iface wlan0 inet manual
    wireless-channel 1
    wireless-essid PiNet
    wireless-mode ad-hoc

#allow-hotplug wlan0
#iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

To get a static IP, I altered my /etc/dhcpcd.conf by adding

interface wlan0
static ip_address=192.168.1.1/24

to the bottom of the file.

I also installed isc-dhcp-server and changed my /etc/default/isc-dhcp-server by adding wlan0 to INTERFACES=''

Finally, I changed my /etc/dhcp/dhcpd.conf by...

  • changing ddns-update-style none; to ddns-update-style interim;
  • uncommenting authoritative;
  • and adding subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.5 192.168.1.100 } to the bottom of the file.

It creates an open network PiNet, but my computer can't connect to it.

Is there anything obvious that I've missed?

CoilKid
  • 121
  • 1
  • 6

1 Answers1

1

After a bit of digging around, I found this. You can basically follow all the instructions, except ignore the bits about configuring network address translation and iptables. It won't create an ad-hoc network per se, but, if you're just trying to SSH into a RPi-based-device when you're in the middle of a field like I was, this should work well.

Generally:

  • install hostapd and dnsmasq on your RPi

  • change your /etc/network/interfaces file to read something like:

    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp
    
    allow-hotplug wlan0
    iface wlan0 init static
     address 192.168.0.1
     netmask 255.255.255.0
     wireless-mode ad-hoc
    
    #allow-hotplug wlan0
    #iface wlan 0 inet manual
    #    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    
  • open your dnsmasq config file (/etc/dnsmasq.conf) and uncomment #dhcp-range=192.168.0.50,192.168.0.150,12h

  • create a hostapd config file (sudo nano /etc/hostapd/hostapd.conf) and enter something to the effect of

    interface=wlan0
    driver=nl80211
    ssid=PiNet
    country_code=US
    hw_mode=g
    channel=6
    macaddr_acl=0
    auth_algs=1
    ignore_broadcast_ssid=0
    wpa=2
    wpa_passphrase=Raspberry
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    wpa_group_rekey=86400
    ieee80211n=1
    wme_enabled=1
    

(Obviously change the ssid and passphrase, and you might have to find the correct driver for your wifi adapter. The guide suggested that you can leave off the driver= line if you're using a RPi 3, I don't know if that's true.)

  • Make sure hostapd knows about the config file. Open /etc/default/hostapd and replace #DAEMON_CONF="" with DAEMON_CONF="/etc/hostapd/hostapd.conf". Open /etc/init.d/hostapd and replace DAEMON_CONF= for DAEMON_CONF=/etc/hostapd/hostapd.conf.

  • Reboot your RPi, connect to it with your favourite device and SSH away!

CoilKid
  • 121
  • 1
  • 6